public synchronized boolean tryLock(){
  try {
    lock=file.tryLock();
    return lock != null;
  }
 catch (  Exception e) {
    return false;
  }
}

public synchronized boolean tryLock ( ) { try { lock = file . tryLock ( ) ; return lock != null ; } catch ( Exception e ) { return false ; } }
try to lock the file .
