public enum RandomAccessFileMode extends Enum<RandomAccessFileMode>
RandomAccessFile with factory methods.| Enum Constant and Description |
|---|
READ_ONLY
Defines mode "r" to open a
RandomAccessFile for reading only. |
READ_WRITE
Defines mode "rw" to open a
RandomAccessFile for reading and writing. |
READ_WRITE_SYNC_ALL
Defines mode "rws" to open a
RandomAccessFile for reading and writing, as with "rw", and also require that every update to the
file's content or metadata be written synchronously to the underlying storage device. |
READ_WRITE_SYNC_CONTENT
Defines mode "rwd" to open a
RandomAccessFile for reading and writing, as with "rw", and also require that every update to the
file's content be written synchronously to the underlying storage device. |
| Modifier and Type | Field and Description |
|---|---|
static String |
R |
static String |
RW |
static String |
RWD |
static String |
RWS |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Path file,
IOConsumer<RandomAccessFile> consumer)
Performs an operation on the
RandomAccessFile specified at the given Path. |
<T> T |
apply(Path file,
IOFunction<RandomAccessFile,T> function)
Applies the given function for a
RandomAccessFile specified at the given Path. |
RandomAccessFile |
create(File file)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
RandomAccessFile |
create(Path file)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
RandomAccessFile |
create(String name)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
String |
getMode()
|
boolean |
implies(RandomAccessFileMode other)
Tests whether this mode implies the given
other mode. |
IORandomAccessFile |
io(String name)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
static RandomAccessFileMode |
valueOf(OpenOption... openOption)
Gets the enum value that best fits the given
OpenOptions. |
static RandomAccessFileMode |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RandomAccessFileMode |
valueOfMode(String mode)
|
static RandomAccessFileMode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RandomAccessFileMode READ_ONLY
RandomAccessFile for reading only.public static final RandomAccessFileMode READ_WRITE
RandomAccessFile for reading and writing.public static final RandomAccessFileMode READ_WRITE_SYNC_ALL
RandomAccessFile for reading and writing, as with "rw", and also require that every update to the
file's content or metadata be written synchronously to the underlying storage device.public static final RandomAccessFileMode READ_WRITE_SYNC_CONTENT
RandomAccessFile for reading and writing, as with "rw", and also require that every update to the
file's content be written synchronously to the underlying storage device.public static final String R
public static final String RW
public static final String RWD
public static final String RWS
public void accept(Path file, IOConsumer<RandomAccessFile> consumer) throws IOException
RandomAccessFile specified at the given Path.
This method allocates and releases the RandomAccessFile given to the consumer.
file - the file specifying the RandomAccessFile to open.consumer - the function to apply.FileNotFoundException - See IORandomAccessFile(File, String).IOException - Thrown by the given function.public <T> T apply(Path file, IOFunction<RandomAccessFile,T> function) throws IOException
RandomAccessFile specified at the given Path.
This method allocates and releases the RandomAccessFile given to the function.
T - the return type of the function.file - the file specifying the RandomAccessFile to open.function - the function to apply.FileNotFoundException - See IORandomAccessFile(File, String).IOException - Thrown by the given function.public RandomAccessFile create(File file) throws FileNotFoundException
File argument.
Prefer create(Path) over this.
file - the file objectFileNotFoundException - See IORandomAccessFile(File, String).public RandomAccessFile create(Path file) throws FileNotFoundException
File argument.file - the file objectFileNotFoundException - See IORandomAccessFile(File, String).public RandomAccessFile create(String name) throws FileNotFoundException
File argument.
Prefer create(Path) over this.
name - the file objectFileNotFoundException - See IORandomAccessFile(File, String).public boolean implies(RandomAccessFileMode other)
other mode.
For example:
READ_WRITE_SYNC_ALL implies {READ_WRITE_SYNC_CONTENT}.READ_WRITE_SYNC_CONTENT implies {READ_WRITE}.READ_WRITE implies {READ_ONLY}.other - the non-null mode to test against.other mode.public IORandomAccessFile io(String name) throws FileNotFoundException
File argument.name - the file objectFileNotFoundException - See IORandomAccessFile(File, String).public static RandomAccessFileMode valueOf(OpenOption... openOption)
OpenOptions.
The input must be a legal and working combination for NIO.
openOption - options like StandardOpenOption.READ_ONLY.StandardOpenOptionpublic static RandomAccessFileMode valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static RandomAccessFileMode valueOfMode(String mode)
public static RandomAccessFileMode[] values()
for (RandomAccessFileMode c : RandomAccessFileMode.values()) System.out.println(c);