Caner
Caner

Reputation: 59168

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 and "USB storage" is off. Any idea why this happens?

Upvotes: 2

Views: 4426

Answers (3)

Pavel Smolensky
Pavel Smolensky

Reputation: 86

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

Upvotes: 0

Dyonisos
Dyonisos

Reputation: 3539

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

Upvotes: 3

Jyosna
Jyosna

Reputation: 4446

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

Upvotes: 0

Related Questions