public final class CanonicalRandomAccessFiles extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CanonicalRandomAccessFiles.FileIOAction |
static class |
CanonicalRandomAccessFiles.FileLockReference |
| Modifier and Type | Method and Description |
|---|---|
static RandomAccessFile |
acquire(File file) |
static void |
acquireExclusiveFileLock(File canonicalFile,
FileChannel channel) |
static void |
acquireSharedFileLock(File canonicalFile,
FileChannel channel) |
static void |
release(File file) |
static void |
releaseExclusiveFileLock(File canonicalFile) |
static void |
releaseSharedFileLock(File canonicalFile) |
static void |
runExclusively(File canonicalFile,
FileChannel fileChannel,
CanonicalRandomAccessFiles.FileIOAction fileIOAction)
Executes a closure under exclusive file lock.
|
static boolean |
tryRunExclusively(File canonicalFile,
FileChannel fileChannel,
CanonicalRandomAccessFiles.FileIOAction fileIOAction)
Tries to execute a closure under exclusive file lock.
|
public static RandomAccessFile acquire(@NotNull File file) throws FileNotFoundException
FileNotFoundExceptionpublic static void release(@NotNull
File file)
public static void acquireSharedFileLock(@NotNull
File canonicalFile,
@NotNull
FileChannel channel)
public static void acquireExclusiveFileLock(@NotNull
File canonicalFile,
@NotNull
FileChannel channel)
public static void releaseSharedFileLock(@NotNull
File canonicalFile)
public static void releaseExclusiveFileLock(@NotNull
File canonicalFile)
public static boolean tryRunExclusively(@NotNull
File canonicalFile,
@NotNull
FileChannel fileChannel,
@NotNull
CanonicalRandomAccessFiles.FileIOAction fileIOAction)
fileIOAction - Closure to run, can throw IOExceptions.true if the lock was successfully acquired and IO action was executed, false otherwise.public static void runExclusively(@NotNull
File canonicalFile,
@NotNull
FileChannel fileChannel,
@NotNull
CanonicalRandomAccessFiles.FileIOAction fileIOAction)
fileIOAction - Closure to run, can throw IOExceptions.Copyright © 2024. All rights reserved.