import java.io.File;
import java.io.IOException;
public class readFile2 {
public static void creatFile(String filePath){
File file=new File(filePath);
if(!file.exists())
{
try {
file.createNewFile();
System.out.println("文件创建成功");
} catch (IOException e) {
e.printStackTrace();
}
}else{
System.out.println("文件已存在");
}
}
public static void creatFileFolder(String filePath){
File file =new File(filePath);
if (!file .exists())
{
file .mkdir();
System.out.println("文件夹创建成功");
}else{
System.out.println("文件夹已存在");
}
}
public static void main(String[] args) {
String filePath1="F:\\test\\test.txt";
String filePath2="F:\\test\\test";
creatFile(filePath1);
creatFileFolder(filePath2);
}
}