Package org.apache.commons.io
Enum RandomAccessFileMode
- All Implemented Interfaces:
- Serializable,- Comparable<RandomAccessFileMode>
Enumerates access modes for 
RandomAccessFile with factory methods.- Since:
- 2.12.0
- See Also:
- 
Enum Constant SummaryEnum ConstantsEnum ConstantDescriptionDefines mode "r" to open aRandomAccessFilefor reading only.Defines mode "rw" to open aRandomAccessFilefor reading and writing.Defines mode "rws" to open aRandomAccessFilefor 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.Defines mode "rwd" to open aRandomAccessFilefor 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.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaccept(Path file, IOConsumer<RandomAccessFile> consumer) Performs an operation on theRandomAccessFilespecified at the givenPath.<T> Tapply(Path file, IOFunction<RandomAccessFile, T> function) Applies the given function for aRandomAccessFilespecified at the givenPath.Constructs a random access file to read from, and optionally to write to, the file specified by theFileargument.Constructs a random access file to read from, and optionally to write to, the file specified by theFileargument.Constructs a random access file to read from, and optionally to write to, the file specified by theFileargument.getMode()Gets the access mode, one of "r", "rw", "rwd", or "rws".booleanimplies(RandomAccessFileMode other) Tests whether this mode implies the givenothermode.Constructs a random access file to read from, and optionally to write to, the file specified by theFileargument.static RandomAccessFileModeReturns the enum constant of this type with the specified name.static RandomAccessFileModevalueOf(OpenOption... openOption) Gets the enum value that best fits the givenOpenOptions.static RandomAccessFileModevalueOfMode(String mode) Gets theRandomAccessFileModevalue for the given mode, one of "r", "rw", "rwd", or "rws".static RandomAccessFileMode[]values()Returns an array containing the constants of this enum type, in the order they are declared.
- 
Enum Constant Details- 
READ_ONLYDefines mode "r" to open aRandomAccessFilefor reading only.- See Also:
 
- 
READ_WRITEDefines mode "rw" to open aRandomAccessFilefor reading and writing.- See Also:
 
- 
READ_WRITE_SYNC_ALLDefines mode "rws" to open aRandomAccessFilefor 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.- See Also:
 
- 
READ_WRITE_SYNC_CONTENTDefines mode "rwd" to open aRandomAccessFilefor 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.- See Also:
 
 
- 
- 
Method Details- 
valuesReturns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
 
- 
valueOfReturns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
- name- the name of the enum constant to be returned.
- Returns:
- the enum constant with the specified name
- Throws:
- IllegalArgumentException- if this enum type has no constant with the specified name
- NullPointerException- if the argument is null
 
- 
valueOfGets the enum value that best fits the givenOpenOptions.The input must be a legal and working combination for NIO. - Parameters:
- openOption- options like- StandardOpenOption.
- Returns:
- best fit, by default READ_ONLY.
- Since:
- 2.18.0
- See Also:
 
- 
valueOfModeGets theRandomAccessFileModevalue for the given mode, one of "r", "rw", "rwd", or "rws".- Parameters:
- mode- one of "r", "rw", "rwd", or "rws".
- Returns:
- A RandomAccessFileMode.
- Throws:
- IllegalArgumentException- Thrown when mode is not one of "r", "rw", "rwd", or "rws".
- Since:
- 2.18.0
 
- 
acceptPerforms an operation on theRandomAccessFilespecified at the givenPath.This method allocates and releases the RandomAccessFilegiven to the consumer.- Parameters:
- file- the file specifying the- RandomAccessFileto open.
- consumer- the function to apply.
- Throws:
- FileNotFoundException- See- IORandomAccessFile(File, String).
- IOException- Thrown by the given function.
- Since:
- 2.18.0
 
- 
applyApplies the given function for aRandomAccessFilespecified at the givenPath.This method allocates and releases the RandomAccessFilegiven to the function.- Type Parameters:
- T- the return type of the function.
- Parameters:
- file- the file specifying the- RandomAccessFileto open.
- function- the function to apply.
- Returns:
- the function's result value.
- Throws:
- FileNotFoundException- See- IORandomAccessFile(File, String).
- IOException- Thrown by the given function.
- Since:
- 2.18.0
 
- 
createConstructs a random access file to read from, and optionally to write to, the file specified by theFileargument.Prefer create(Path)over this.- Parameters:
- file- the file object
- Returns:
- a random access file
- Throws:
- FileNotFoundException- See- IORandomAccessFile(File, String).
 
- 
createConstructs a random access file to read from, and optionally to write to, the file specified by theFileargument.- Parameters:
- file- the file object
- Returns:
- a random access file
- Throws:
- FileNotFoundException- See- IORandomAccessFile(File, String).
 
- 
createConstructs a random access file to read from, and optionally to write to, the file specified by theFileargument.Prefer create(Path)over this.- Parameters:
- name- the file object
- Returns:
- a random access file
- Throws:
- FileNotFoundException- See- IORandomAccessFile(File, String).
 
- 
getModeGets the access mode, one of "r", "rw", "rwd", or "rws".- Returns:
- one of "r", "rw", "rwd", or "rws".
- Since:
- 2.18.0
 
- 
impliesTests whether this mode implies the givenothermode.For example: - READ_WRITE_SYNC_ALLimplies {- READ_WRITE_SYNC_CONTENT}.
- READ_WRITE_SYNC_CONTENTimplies {- READ_WRITE}.
- READ_WRITEimplies {- READ_ONLY}.
 - Parameters:
- other- the non-null mode to test against.
- Returns:
- whether this mode implies the given othermode.
- Since:
- 2.18.0
 
- 
ioConstructs a random access file to read from, and optionally to write to, the file specified by theFileargument.- Parameters:
- name- the file object
- Returns:
- a random access file
- Throws:
- FileNotFoundException- See- IORandomAccessFile(File, String).
- Since:
- 2.18.0
 
 
-