I am trying to access a file to read it and write on it using this code:
RandomAccessFile file1 = new RandomAccessFile("C:\\lol.txt", "rw");
It returns me an error "File not Found (IOException)".
The file exists and it is in that exact folder. What am I missing?
Unless your run your Java application as an administrator, you won't have write access to
C:
.The following code
will give you
The javadoc for
RandomAccessFile
constructor states this:Just move your file to another location, like
C:\Users\You
.