• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access Denied Error with RandomAccessFile

 
Kedarnath Bhagwat
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am accessing the file using RandomAccessFile .
I get following error
Exception in thread "main" java.lang.RuntimeException: The given file does not exist.
at scjd.DBFileReader.main(DBFileReader.java:213)
Caused by: java.io.FileNotFoundException: C:\db-1x3.db (Access is denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at scjd.DBFileReader.main(DBFileReader.java:100)
Java Result: 1


The file exists at the location and if I only read is successful operation with parameter "r"
If I pass "rw" then I get the above error.

Can anyone help me with this error .
 
Kedarnath Bhagwat
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops ! I figured it out .
I put the file in C:\ drive . It was giving me only read access .
I created C:\test folder and put the db file there .
And now I don't get the error 'Access Denied' .

Isn't this weired ?
 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It must have been read only access. Once you placed in the folder the folder must not have read only access!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic