If the d: \ upload \ file \ folder does not exist, an error
String strPath = "d:\\upload\\file\\2.mp3"; File file = new File(strPath); if(!file.exists())){ file.createNewFile(); }
The following will create a folder d: \\ upload \\ file \\ 2.mp3 \
String strPath = "d:\\upload\\file\\2.mp3"; File file = new File(strPath); if(!file.exists())){ file.file.mkdirs(); }
This code can successfully create a file
String strPath = "d:\\upload\\file\\2.mp3"; File file = new File(strPath); File fileParent = file.getParentFile(); if(!fileParent.exists()){ fileParent.mkdirs(); } file.createNewFile();