package test;
import java.io.File;
import java.io.IOException;
public class Test {
public static void main(String[] args) {
createFile();
}
public static void createFile(){
String path = "d:/mydirector";
File f = new File(path);
if(!f.exists()){
f.mkdirs();
}
String fileName="test.txt";
File file = new File(f,fileName);
if(!file.exists()){
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
给分吧,执行了次,没有Bug。