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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories