mkdir() is not creating the new directory

后端 未结 7 2209
庸人自扰
庸人自扰 2020-12-18 20:59

I am using Eclipse and jdk1.7. I am making a basic program using file handling, in which an output directory inside the directory is to be made. But when I run the program,

7条回答
  •  执念已碎
    2020-12-18 21:32

    In your case you can make use of makedirectories method in File class.

    File dir = new File("path name");
    boolean isCreated = dir.mkdirs();
    

    Here makedirectories method will create all directories that are missing in the path which the file object represent.

    Source and reference is below (explained in detail).

    http://www.flowerbrackets.com/create-directory-java-program/

    https://docs.oracle.com/javase/6/docs/api/java/io/File.html#canWrite%28%29

提交回复
热议问题