Create a directory if it does not exist and then create the files in that directory as well

前端 未结 7 1256
礼貌的吻别
礼貌的吻别 2020-12-12 14:36

Condition is if directory exists it has to create files in that specific directory with out creating a new directory.

The below code only creating a file with new di

7条回答
  •  渐次进展
    2020-12-12 15:23

    java 8+ version

    Files.createDirectories(Paths.get("/Your/Path/Here"));
    

    The Files.createDirectories

    creates a new directory and parent directories that do not exist.

    The method does not thrown an exception if the directory already exist.

提交回复
热议问题