I'm writing a java app that reads a File every second using FileInputStream (it's inside an infinite loop in a seperate thread, that then sleeps for 1 second)
The file is opened in another application.
When I try to save the file in the other application, I get an error message that the file is being used by another program.
I read the FileLock API, and implemented lock and release on writing and reading:
FileOutputStream fos = new FileOutputStream(file);
FileLock fileLock = fos.getChannel().lock();
if (fileLock != null) {
fos.write(fileContent);
fileLock.release();
}
fos.close();
How do I disable the file lock on a file that 2 applications are accessing?
Thank you!!
edit: I'm debugging on WINDOWS 7