public enum RandomAccessFileMode extends java.lang.Enum<RandomAccessFileMode>
RandomAccessFile with factory methods.RandomAccessFile.RandomAccessFile(File, String),
RandomAccessFile.RandomAccessFile(String, String),
Enum| Enum Constant and Description |
|---|
READ_ONLY
Defines mode to open a
RandomAccessFile for reading only. |
READ_WRITE
Defines mode to open a
RandomAccessFile for reading and writing. |
READ_WRITE_SYNC_ALL
Defines mode to open a
RandomAccessFile for reading and writing, as with , 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 to open a
RandomAccessFile for reading and writing, as with , and also require that every update to the
file's content be written synchronously to the underlying storage device. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(java.nio.file.Path file,
IOConsumer<java.io.RandomAccessFile> consumer)
Performs an operation on the
RandomAccessFile specified at the given Path. |
<T> T |
apply(java.nio.file.Path file,
IOFunction<java.io.RandomAccessFile,T> function)
Applies the given function for a
RandomAccessFile specified at the given Path. |
java.io.RandomAccessFile |
create(java.io.File file)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
java.io.RandomAccessFile |
create(java.nio.file.Path file)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
java.io.RandomAccessFile |
create(java.lang.String name)
Constructs a random access file to read from, and optionally to write to, the file specified by the
File argument. |
java.lang.String |
getMode()
Gets the access mode, one of , , , or .
|
boolean |
implies(RandomAccessFileMode other)
Tests whether this mode implies the given
other mode. |
IORandomAccessFile |
io(java.lang.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(java.nio.file.OpenOption... openOption)
Gets the enum value that best fits the given
OpenOptions. |
static RandomAccessFileMode |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static RandomAccessFileMode |
valueOfMode(java.lang.String mode)
Gets the
RandomAccessFileMode value for the given mode, one of , , , or . |
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.RandomAccessFile.RandomAccessFile(File, String),
RandomAccessFile.RandomAccessFile(String, String)public static final RandomAccessFileMode READ_WRITE
RandomAccessFile for reading and writing.RandomAccessFile.RandomAccessFile(File, String),
RandomAccessFile.RandomAccessFile(String, String)public static final RandomAccessFileMode READ_WRITE_SYNC_ALL
RandomAccessFile for reading and writing, as with , and also require that every update to the
file's content or metadata be written synchronously to the underlying storage device.RandomAccessFile.RandomAccessFile(File, String),
RandomAccessFile.RandomAccessFile(String, String),
StandardOpenOption.SYNCpublic static final RandomAccessFileMode READ_WRITE_SYNC_CONTENT
RandomAccessFile for reading and writing, as with , and also require that every update to the
file's content be written synchronously to the underlying storage device.RandomAccessFile.RandomAccessFile(File, String),
RandomAccessFile.RandomAccessFile(String, String),
StandardOpenOption.DSYNCpublic static RandomAccessFileMode[] values()
for (RandomAccessFileMode c : RandomAccessFileMode.values()) System.out.println(c);
public static RandomAccessFileMode valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic static RandomAccessFileMode valueOf(java.nio.file.OpenOption... openOption)
OpenOptions.
The input must be a legal and working combination for NIO.
openOption - options like StandardOpenOption.READ_ONLY.StandardOpenOptionpublic static RandomAccessFileMode valueOfMode(java.lang.String mode)
RandomAccessFileMode value for the given mode, one of , , , or .mode - one of , , , or .java.lang.IllegalArgumentException - Thrown when mode is not one of , , , or .public void accept(java.nio.file.Path file,
IOConsumer<java.io.RandomAccessFile> consumer)
throws java.io.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.java.io.FileNotFoundException - See IORandomAccessFile.IORandomAccessFile(File, String).java.io.IOException - Thrown by the given function.public <T> T apply(java.nio.file.Path file,
IOFunction<java.io.RandomAccessFile,T> function)
throws java.io.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.java.io.FileNotFoundException - See IORandomAccessFile.IORandomAccessFile(File, String).java.io.IOException - Thrown by the given function.public java.io.RandomAccessFile create(java.io.File file)
throws java.io.FileNotFoundException
File argument.
Prefer create(Path) over this.
file - the file objectjava.io.FileNotFoundException - See IORandomAccessFile.IORandomAccessFile(File, String).public java.io.RandomAccessFile create(java.nio.file.Path file)
throws java.io.FileNotFoundException
File argument.file - the file objectjava.io.FileNotFoundException - See IORandomAccessFile.IORandomAccessFile(File, String).public java.io.RandomAccessFile create(java.lang.String name)
throws java.io.FileNotFoundException
File argument.
Prefer create(Path) over this.
name - the file objectjava.io.FileNotFoundException - See IORandomAccessFile.IORandomAccessFile(File, String).public java.lang.String getMode()
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(java.lang.String name) throws java.io.FileNotFoundException
File argument.name - the file objectjava.io.FileNotFoundException - See IORandomAccessFile.IORandomAccessFile(File, String).Copyright © 2010 - 2025 Adobe. All Rights Reserved