Class LockableFile
java.lang.Object
net.adoptopenjdk.icedteaweb.lockingfile.LockableFile
Process invalid input: '&' thread lockable access to a file. Creates file if it does not already exist.
-
Method Summary
Modifier and TypeMethodDescriptiongetFile()Get the file being locked.static LockableFilegetInstance(File file) Get a LockableFile for a given File.booleanbooleanvoidlock()Lock access to the file.Lock is reentrant.booleantryLock()voidunlock()Unlock access to the file.Lock is reentrant.
-
Method Details
-
getInstance
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
Get the file being locked.- Returns:
- the file
-
isReadOnly
public boolean isReadOnly()- Returns:
- if the file is read only.
-
lock
Lock access to the file.Lock is reentrant.- Throws:
IOException- if an I/O error occurs.
-
tryLock
public boolean tryLock() -
unlock
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()
-