如果 d:\upload\file\ 文件夹不存在,会报错
String strPath = "d:\\upload\\file\\2.mp3";
File file = new File(strPath);
if(!file.exists())){
file.createNewFile();
}
String strPath = "d:\\upload\\file\\2.mp3";
File file = new File(strPath);
if(!file.exists())){
file.file.mkdirs();
}
String strPath = "d:\\upload\\file\\2.mp3";
File file = new File(strPath);
File fileParent = file.getParentFile();
if(!fileParent.exists()){
fileParent.mkdirs();
}
file.createNewFile();