Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (5.3k points)

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.

1 Answer

0 votes
by (26.4k points)

Try following code:

File theDir = new File("/path/directory");

if (!theDir.exists()){

    theDir.mkdirs();

}

Want to learn more about Java? Come and Join:- Core Java certification course

Related questions

0 votes
1 answer
asked Aug 11, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...