Java code to create directory along with required nonexistent parent directories
// Java code to create directory along with required
// nonexistent parent directories
import java.io.*;
public class CreateDIRwithParentDIRs {
public static void main(String[] args) {
// create File object with directories
File dirs = new File("C://course//semester1//programming//java");
// variable to store result
// and method call to create directories
boolean result = dirs.mkdirs();
if (result)
System.out.println("Directories created sucessfully...");
else
System.out.println("Error occured...");
}
}
Java code to create directory along with required nonexistent parent directories
Output