How to create a directory in Java?

jimmy picture jimmy · Sep 3, 2010 · Viewed 595.9k times · Source

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.

Answer

Bozho picture Bozho · Sep 3, 2010
new File("/path/directory").mkdirs();

Here "directory" is the name of the directory you want to create/exist.