title: Check if a file is locked in Java
body: <p>My Java program wants to read a file which can be locked by another program writing into it.  I need to check if the file is locked and if so wait until it is free.  How do I achieve this?</p>
  
  <p>The Java program is running on a Windows 2000 server.</p>