How safe is it to use Java FileLock?
<p>How safe is it to use <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileLock.html" rel="nofollow noreferrer">java.nio.channels.FileLock</a> for locking files among processes? It is stated that other processes can not access the file if we have an exclusive lock. However, the below answer on another <a href="https://stackoverflow.com/questions/2268997/java-filelock-for-reading-and-writing">SO question</a> states other processes have to check for the filelock too in order for our process to be safe.</p>

<blockquote>
  <p>(a) Are you aware that locking the file won't keep other processes from touching it unless they also use locks?</p>
</blockquote>

<p>So I tested my code and tried to change, a file which I have the lock already, with <em>Windows Text Editor</em> and I was safe from harm but not when I test with <em>Notepad++</em>..</p>

<p>Is there a solution for locking a file appropriately in Java 6?</p>