Search code examples
javaandroidfilenotfoundexceptionrandom-access

java.io.FileNotFoundException when using RandomAccessFile to create file


I'm encountering a FileNotFoundException when I try to make a file using RandomAccessFile:

RandomAccessFile file = new RandomAccessFile("/test.jpg", "rw");

I don't now how to get around this. It's driving me nuts.

Thanks


Solution

  • Try

    RandomAccessFile file = new RandomAccessFile(new File(getFilesDir(), "test.jpg"),
            "rw");