Constructor and Description |
---|
FileLock(String fullPath)
Initialize a FileLock using a file located at fullPath.
|
FileLock(String parentDir,
String fileName)
Initialize a FileLock using a file located at parentDir/fileName.
|
Modifier and Type | Method and Description |
---|---|
static FileLock |
inTempFolder(String fileName)
Initialize a FileLock using a file located inside temp folder.
|
boolean |
isValid()
Check whether a FileLock is actually holding the lock.
|
boolean |
tryLock()
Try to acquire a lock on the locking file.
|
void |
unlock()
Release the file lock.
|
void |
unlockAndDestroy()
Release the file lock, close the fileChannel and FileOutputStream then try deleting the
locking file if other file lock does not need it, which means the lock will not be used
anymore.
|
public FileLock(String fullPath)
fullPath
- The path of the locking filepublic static FileLock inTempFolder(String fileName)
fileName
- The name of the locking filepublic boolean tryLock() throws IOException
IOException
- If the file path is invalidpublic void unlock() throws IOException
IOException
- If the FileChannel is closedpublic void unlockAndDestroy() throws IOException
IOException
- If an I/O error occurspublic boolean isValid()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.