if (file.exists()) { 来判断这是不是一个文件。
file.isDirectory() 来判断这是不是一个文件夹。
1.File testFile = new File(testFilePath);
if(!testFile .exists()) {
testFile.mkdirs();
System.out.println("测试文件夹不存在");
}
2.File testFile = new File(testFilePath);
if(!testFile .exists()) {
testFile.createNewFile();
System.out.println("测试文件不存在");
}