Java's createNewFile() - will it also create directories?

后端 未结 6 859
野趣味
野趣味 2020-12-13 08:20

I\'ve got a conditional to check if a certain file exists before proceeding (./logs/error.log). If it isn\'t found I want to create it. However, will

         


        
6条回答
  •  悲哀的现实
    2020-12-13 08:34

    No, and if logs does not exist you'll receive java.io.IOException: No such file or directory

    Fun fact for android devs: calls the likes of Files.createDirectories() and Paths.get() would work when supporting min api 26.

提交回复
热议问题