I have some corruption problems with property files. What I suspect is that concurrent reading/writing is the problem. So I want to put some file locks.
First I have looked at this: How can I lock a file using java (if possible)
So I can put locks on write, but not on read, which does not solve my problem.
Then I have looked at this: Java: how to handle two process trying to modify the same file
So if I use RandomAccessFile, I can put lock on read AND write, which seems correct. So my remaining problem is simple: load a Property with RandomAccessFile. But I see no simple way to have a Reader or an InputStream from a RandomAccessFile. Is there one?
Thanks,
Guillaume
Edit: As there is some ambiguity, I have to add that the concurrency is due to multiple processes accessing the file, not multithreading