String path = "D:\File\file1.txt";
[color=red]如果D盘下没有File文件夹,那么怎么创建path的文件呢?[/color]谢谢!
[code]
String path = "D:\a\b\c\d.txt";
File f = new File(path);
File pf = f.getParentFile();
if (!pf.exists()) {
pf.mkdirs();
}
if (!f.exists()) {
f.createNewFile();
}
[/code]