Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (10.2k points)
reshown by

How do I create a Directory/folder?

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

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

1 Answer

0 votes
by (119k points)
reshown by

Here are the two methods to create a directory in Java:

Method 1:

new File("/path/directory").mkdirs();

In this, "directory" represents the name of the directory you want to create/exist.

Method 2:

You can use FileUtils.forceMkdir


If you want to learn Java, you can register for this Java Course by Intellipaat.

Browse Categories