How to create a folder in Java?

user364669 picture user364669 · Jun 11, 2010 · Viewed 17.4k times · Source

How can I create an empty folder in Java?

Answer

Luc M picture Luc M · Jun 11, 2010
File f = new File("C:\\TEST");
try{
    if(f.mkdir()) { 
        System.out.println("Directory Created");
    } else {
        System.out.println("Directory is not created");
    }
} catch(Exception e){
    e.printStackTrace();
}