File.createNewFile() thowing IOException No such file or directory

后端 未结 9 2478
感动是毒
感动是毒 2020-12-15 03:51

I have a method that writes to a log file. If the file exists it should append to it, if not then I want it to create a new file.

if (!file.exists() &&am         


        
9条回答
  •  青春惊慌失措
    2020-12-15 04:05

    //Create New File if not present
    if (!file.exists()) {
        file.getParentFile().mkdirs();
    
        file.createNewFile();
        Log.e(TAG, "File Created");
    }
    

提交回复
热议问题