To create a folder in Java you can use on of these 2 Methods

Sample Java

boolean done = (new File("directoryName")).mkdir();  // all ancestor directories must exist!
if (!done) {  
    // failed ()  
}  

Sample Java

boolean done = (new File("directoryName")).mkdirs(); // all directories will be created   
if (!done) {  
    // failed  
}  

One thought on “How to create a folder in Java”

Leave a Reply