This may appear a silly question, but I wanted to know if I opened a file using the RandomAccessFile implementation found within Java would cause an Access Violation if a program externally accessed or edited this file
Logic in my head dictated ‘NO’ it wouldn’t. So I put it too the test, attached below:
Here I’m basically spawning a 4 threads to open a file and start getting information from the file.he Thread class implementation:
After running this, and even making an edit to the file via NOTEPAD, this is the result:
As you can see now ACCESS VIOLATION within my PROGRAM, and even alterations outside the program do not affect the END RESULT, as all the above RandomAccessFile constructs were initialized at more or less similar moment in time, with a snapshot of the ‘textfile’, thus it does not reflect new changes I have made, since the ‘initialization’.
RandomAccessFile fileHandler = new RandomAccessFile(file, “r”);
Ok, enuff said!