Click here to watch in Youtube :
https://www.youtube.com/watch?v=boWBpNkdIvo&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java IO (Java File - How to create the directory) |
import java.io.File; public class FileDemo1 { public static void main(String[] args) { File file = new File("D:/work/java"); /* * Creates the directory named by this abstract * pathname. * * Returns: true if and only if the directory was * created; false otherwise */ boolean dirCreated = file.mkdir(); System.out.println(file.getAbsolutePath() + " directory Created? = " + dirCreated); } }
OutputD:\work\java directory Created? = true
import java.io.File; public class FileDemo2 { public static void main(String[] args) { File file = new File("D:/work/java/arraylist/src"); /* * Creates the directory named by this abstract * pathname, including any necessary but nonexistent * parent directories. * * Returns: true if and only if the directory was * created, along with all necessary parent * directories; false otherwise */ boolean dirCreated = file.mkdirs(); System.out.println(file.getAbsolutePath() + " directory Created ? = " + dirCreated); } }
D:\work\java\arraylist\src directory Created ? = true
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_File_CreateDir_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_File_CreateDir_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/882ffbbbc9c8fbb765fb4869059bc3ee253ad31b/BasicJava/JavaIODemo_File_CreateDir_App/?at=master
See also:
No comments:
Post a Comment