1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* Create directory This Java example shows how to create a directory in the filesystem using mkdir method of Java File class. */ import java.io.*; public class CreateDirectory { public static void main(String[] args) { //create file object File dir = new File("C://FileIO//DemoDirectory"); /* * To create directory in the filesystem use, * boolean mkdir() method of Java File class. * * This method returns true if the directory was created successfully, false * otherwise. */ boolean isDirectoryCreated = dir.mkdir(); if(isDirectoryCreated) System.out.println("Directory created successfully"); else System.out.println("Directory was not created successfully"); } } /* Output would be Directory created successfully */ |
Add Comment