java 在给定路径上创建文件,所在文件夹不存在时,如何正确创建
String path = "D:\\b\\bb\\bbb.xlsx";
File file = new File(path);
File fileParent = file.getParentFile();
if(!fileParent.exists()){
fileParent.mkdirs();
}
file.createNewFile();
String path = "D:\\b\\bb\\bbb.xlsx";
File file = new File(path);
File fileParent = file.getParentFile();
if(!fileParent.exists()){
fileParent.mkdirs();
}
file.createNewFile();