package com
import java
import java
public class CreateFileUtil {
public static boolean CreateFile(String destFileName) {
File file = new File(destFileName);
if (file
System
return false;
}
if (destFileName
System
return false;
}
if (!file
System
if (!file
System
return false;
}
}
// 創建目標文件
try {
if (file
System
return true;
} else {
System
return false;
}
} catch (IOException e) {
e
System
return false;
}
}
public static boolean createDir(String destDirName) {
File dir = new File(destDirName);
if(dir
System
return false;
}
if(!destDirName
destDirName = destDirName + File
// 創建單個目錄
if(dir
System
return true;
} else {
System
return false;
}
}
public static String createTempFile(String prefix
File tempFile = null;
try{
if(dirName == null) {
// 在默認文件夾下創建臨時文件
tempFile = File
return tempFile
}
else {
File dir = new File(dirName);
// 如果臨時文件所在目錄不存在
if(!dir
if(!CreateFileUtil
System
return null;
}
}
tempFile = File
return tempFile
}
} catch(IOException e) {
e
System
return null;
}
}
public static void main(String[] args) {
// 創建目錄
String dirName =
CreateFileUtil
// 創建文件
String fileName = dirName +
CreateFileUtil
// 創建臨時文件
String prefix =
String suffix =
for(int i =
System
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25690.html