snippetjavaCritical
How to create a directory in Java?
Viewed 0 times
directoryhowjavacreate
Problem
How do I create Directory/folder?
Once I have tested
I have to create a directory (directory name "new folder" ) if and only if new folder does not exist.
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.
Solution
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();
}Code Snippets
File theDir = new File("/path/directory");
if (!theDir.exists()){
theDir.mkdirs();
}Context
Stack Overflow Q#3634853, score: 567
Revisions (0)
No revisions yet.