[英]File Not Found when trying to create a PrintWriter, Android Studio
我正在嘗試編輯內部存儲中的文件(因此不需要權限,對嗎?),但是當我運行此代碼時:
String locus = getFilesDir().getAbsolutePath();
File locusfile = new File(locus);
String loglocation = locus + "/log.txt";
File log = new File(loglocation);
if(log.exists())
{
PrintWriter pw = new PrintWriter(log);
}
PrintWriter pw帶有“ FileNotFoundException”。
為什么即使我確認文件存在,也會發生這種情況?
謝謝。
嘗試添加log.createNewFile();
在File log = new File(loglocation);
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.