Package de.stefanfrings.utils
Class LockFile
java.lang.Object
de.stefanfrings.utils.LockFile
Lock files are used to protect files against concurrent access.
Using lock files is often declared as deprecated, but I still use them sometimes, because it works fine on all filesystem.
- Author:
- Stefan Frings, http://stefanfrings.de/javautils
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
LockFile
public LockFile()
-
-
Method Details
-
lock
Create a lock file. If the lock file does already exist, this method waits a while.- Parameters:
file
- File that shall be locked. The lock file will have the same name with additional suffix ".lock".seconds
- Maximum seconds to wait- Throws:
IOException
- In case of an I/O errorInterruptedException
- If the waiting loop got interrupted.
-
release
Delete a lock file. Nothing happens if the file does not exist.- Parameters:
file
- The lock file to delete.
-