主题:请问创建文件夹
maskhe
[专家分:150] 发布于 2009-07-13 14:28:00
请问如何获取文件名称,然后建立这个名字的文件夹, 然后再获取这个文件夹的路径
谢谢
最后更新于:2009-07-13 14:29:00
回复列表 (共1个回复)
沙发
maskhe [专家分:150] 发布于 2009-07-15 22:08:00
问题已经解决
public void copyFile(String paramString1, FileInputStream paramFileInputStream, String paramString2)
{
try
{
String str3;
FileOutputStream localFileOutputStream;
byte[] arrayOfByte;
int j;
int i = paramString1.lastIndexOf(".");
String str1 = paramString1.substring(0, i);
String str2 = paramString1 + paramString2;
File localFile = new File(str1);
if ((!(localFile.exists())) && (!(localFile.isDirectory())))
{
localFile.mkdir();
str3 = localFile.getPath() + "/" + paramString2;
localFileOutputStream = new FileOutputStream(str3);
arrayOfByte = new byte[1024];
j = 0;
while ((j = paramFileInputStream.read(arrayOfByte)) != -1)
{
localFileOutputStream.write(arrayOfByte, 0, j);
}
paramFileInputStream.close();
localFileOutputStream.close();
}
else if ((localFile.exists()) && (localFile.isDirectory()))
{
localFile.setWritable(true);
str3 = localFile.getPath() + "/" + paramString2;
localFileOutputStream = new FileOutputStream(str3);
arrayOfByte = new byte[1024];
j = 0;
while ((j = paramFileInputStream.read(arrayOfByte)) != -1)
{
localFileOutputStream.write(arrayOfByte, 0, j);
}
paramFileInputStream.close();
localFileOutputStream.close();
}
}
catch (IOException localIOException)
{
System.out.println("Error");
}
}
我来回复