I need to check if a position in a random access file has not been written to. The problem with this is, when the position actually hasn't been written to, I get (as anticipated) an EOFException. I have been reading RandomAccessFile documentation to try to solve this problem, and tried researching online.
Things I've tried:
Using a try-catch block and catching every time there is a EOFException (Using try-catch as a conditional statement). It works, but it is horrible practice, and it is very inefficient, as for my case it is EOF the majority of the time.
Using a BufferReader to loop through and check the position. I ended up running into many problems and decided that there must be a better way.
I don't want to do any copying one file over to another or any other work around. I know there has to be a direct way of doing this, I just can't seem to find the correct solution.