开发者

java.io.FileNotFoundException with FileWriter

The following line

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

throws:

java.io.FileNotFoundException: /log0.txt (Read-only file system)

I'm testing this on device an开发者_JAVA技巧d "USB storage" is off. Any idea why this happens?


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()

See also:

http://developer.android.com/guide/topics/data/data-storage.html


Make sure log0.txt is present in ur device. Other wise it give exception


Here is a tutorial, which begins describing your issue. It will be helpful to read.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜