public boolean isLocked() throws IOException {
  try (FileLock fl=fileToLock.tryLock()){
    return fl != null;
  }
 catch (  OverlappingFileLockException e) {
    return true;
  }
}

public boolean isLocked ( ) throws IOException { try ( FileLock fl = fileToLock . tryLock ( ) ) { return fl != null ; } catch ( OverlappingFileLockException e ) { return true ; } }
returns wether the underlying file is locked , non - blocking .
