import java.io.*;
public class Fan {
public static void main(String[] args) {
String path ="d://upload_test//file"; //設置一個默認文件夾路徑
File uploadFilePath = new File(path);
// 如果該目錄不存在,則創建之
if(uploadFilePath.exists() == false) {
uploadFilePath.mkdirs();
System.out.println("路徑不存在,但是已經成功創建了" + path);
}else{
System.out.println("文件路徑存在" + path);
}
String filePath = path+"//xin.txt";
File createFile = new File(filePath);
try {
createFile.createNewFile();
System.out.println("文件創建成功!");
} catch (IOException e) {
System.out.println("文件創建失敗了!");
e.printStackTrace();
}
}
}