Skip to content
Advertisement

How to create a directory in Java?

How do I create Directory/folder?

Once I have tested System.getProperty("user.home");

I have to create a directory (directory name “new folder” ) if and only if new folder does not exist.

Advertisement

Answer

After ~7 year, I will update it to better approach which is suggested by Bozho.

File theDir = new File("/path/directory");
if (!theDir.exists()){
    theDir.mkdirs();
}
Advertisement