public class FileLocker
extends java.lang.Object
implements java.io.Closeable
构造器和说明 |
---|
FileLocker(java.io.File lockFile)
构造一个文件锁对象
|
限定符和类型 | 方法和说明 |
---|---|
void |
close()
关闭
|
java.io.File |
getLockFile()
获取加锁的文件
|
java.io.RandomAccessFile |
getRandomAccessFile()
获取随机读写对象,加锁后,需要通过这个对象对文件进行操作。
|
void |
release()
解锁文件
|
boolean |
tryLock()
尝试加锁文件,加锁后需要调用解锁才能解除锁定
|
public boolean tryLock()
release()
public void release()
public java.io.RandomAccessFile getRandomAccessFile()
public java.io.File getLockFile()
public void close()