请问public File(String parent, String child)是怎么用来创建文件的。
直接用File file = new File("E:/aa","hi.txt");
file.createNewFile()
创建失败,报错:Exception in thread "main" java.io.IOException: 系统找不到指定的路径。
直接用File file = new File("E:/aa","hi.txt");
file.createNewFile()
创建失败,报错:Exception in thread "main" java.io.IOException: 系统找不到指定的路径。
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
file.createNewFile();