java.io.FileNotFoundException用的FileWriter [英] java.io.FileNotFoundException with FileWriter

查看:457
本文介绍了java.io.FileNotFoundException用的FileWriter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下行

FileWriter fw = new FileWriter("/log0.txt");

抛出:结果
java.io.FileNotFoundException:/log0.txt(只读文件系统)

我测试此设备​​上和USB存储设备是关闭的。任何想法,为什么出现这种情况?

I'm testing this on device and "USB storage" is off. Any idea why this happens?

推荐答案

您正试图创建的根路径/的文件。尝试像/数据/或到/ mnt / SD卡或使用方法写的路径创建文件: Environment.getExternalStorageDirectory()

You are trying to create a file in the root path "/". Try to create the file in a writable path like "/data/" or "/mnt/sdcard" or use the methods: Environment.getExternalStorageDirectory()

另请参阅:

http://developer.android.com/guide/topics/数据/数据​​storage.html

这篇关于java.io.FileNotFoundException用的FileWriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆