public void createFile() {
// path表示你所创建文件的路径
String path = "d:/tr/rt";
File f = new File(path);
if (!f.exists()) {
f.mkdirs();
}
// fileName表示你创建的文件名;为txt类型;
String fileName = "test.txt";
File file = new File(f, fileName);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// 现在你可以在d:/tr/rt 目录下找到test.txt文件