1ow*_*k3y 9 java android android-context java-io android-file
Android Developer参考(本页)说:
Throws FileNotFoundException
Run Code Online (Sandbox Code Playgroud)
但在一开始,它说:
打开与此Context的应用程序包关联的私有文件以进行写入.如果文件尚不存在,则创建该文件.
如果是这种情况,为什么会抛出FileNotFoundException?
我只是想确保我正确处理所有案件.我正在使用默认功能,所以我可以将它包装在try..catch块中没有任何内容的catch块中,因为它不可能FileNotFoundException被抛出默认功能吗?
编辑: '默认功能'的示例:
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = context.openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
Run Code Online (Sandbox Code Playgroud)