Class LockableFile

java.lang.Object
net.adoptopenjdk.icedteaweb.lockingfile.LockableFile

public class LockableFile extends Object
Process invalid input: '&' thread lockable access to a file. Creates file if it does not already exist.
  • Method Details

    • getInstance

      public static LockableFile getInstance(File file)
      Get a LockableFile for a given File. Ensures that we share the same instance for all threads.
      Parameters:
      file - the file to lock
      Returns:
      a LockableFile instance
    • getFile

      public File getFile()
      Get the file being locked.
      Returns:
      the file
    • isReadOnly

      public boolean isReadOnly()
      Returns:
      if the file is read only.
    • lock

      public void lock() throws IOException
      Lock access to the file.Lock is reentrant.
      Throws:
      IOException - if an I/O error occurs.
    • tryLock

      public boolean tryLock()
    • unlock

      public void unlock() throws IOException
      Unlock access to the file.Lock is reentrant. Does not do anything if not holding the lock.
      Throws:
      IOException - if an I/O error occurs.
    • isHeldByCurrentThread

      public boolean isHeldByCurrentThread()