Hello there I want to create the directories and sub directories with the java. My directory structure is starts from the current application directory, Means in current pro
You could do it with File#mkdirs() and something like,
// The "/" is cross-platform safe as a path-separator in Java.
// So is "\\" but that's twice the characters!
String path = createImages.getAbsolutePath() + "/Images";
File f = new File(path);
if (!f.isDirectory()) {
boolean success = f.mkdirs();
if (success) {
System.out.println("Created path: " + f.getPath());
} else {
System.out.println("Could not create path: " + f.getPath());
}
} else {
System.out.println("Path exists: " + f.getPath());
}
Per the linked Javadoc,
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.