How to create a directory in Java?
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();
}
With Java 7, you can use Files.createDirectories()
.
For instance:
Files.createDirectories(Paths.get("/path/to/directory"));
new File("/path/directory").mkdirs();
Here "directory" is the name of the directory you want to create/exist.