Create directory and directories recursively(mkdir)
import java.io.File;
public class Main {
public static void main(String[] args) {
boolean status;
status = new File("/home/a/bin").mkdir();
System.out.println(status ? "success" : "failure");
status = new File("/home/a/src").mkdir();
System.out.println(status ? "success" : "failure");
status = new File("/home/a/once/twice/again").mkdir(); // fail
System.out.println(status ? "success" : "failure");
status = new File("/home/a/once/twice/again").mkdirs(); // succeed
System.out.println(status ? "success" : "failure");
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
IO Directory:
- Create directory and directories recursively(mkdir)
- List all files under directory recursively, like UNIX ls or DOS and VMS dir
- List root directory