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

后端 未结 6 849
野趣味
野趣味 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:44

    File theDir = new File(DirectoryPath);
    if (!theDir.exists()) theDir.mkdirs();
    

提交回复
热议问题