//file object creation by passing the path
File file = new File("d://course");
//creating directory named "course" in "d://" drive
file.mkdir();
Output:
true
//Java code to create a directory
import java.io.*;
public class Main {
public static void main(String[] args) {
//file object creation by passing the path
//where we have to create the directory
File file = new File("d://course");
//variable to store the result
//assigning false as an initial value
boolean result = false;
//creating directory named "course" in "d://" drive
result = file.mkdir();
if (result == true) {
System.out.println("Directory created successfully...");
} else {
System.out.println("Directory is not created...");
}
}
}
Java code to create a directory
Output