org.apache.commons.io

## Enum RandomAccessFileMode

- java.lang.Object
- - java.lang.Enum<RandomAccessFileMode>
  - - org.apache.commons.io.RandomAccessFileMode

- All Implemented Interfaces:
    Serializable, Comparable<RandomAccessFileMode>

      public enum RandomAccessFileMode
      extends Enum<RandomAccessFileMode>

  Access modes and factory methods for `RandomAccessFile`.
  Since:
    2.12.0

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `READ_ONLY` Mode "r" opens for reading only.
    `READ_WRITE` Mode "rw" opens for reading and writing.
    `READ_WRITE_SYNC_ALL` Mode "rws" opens 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` Mode "rwd" open 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.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `RandomAccessFile` | `create(File file)` Creates a random access file stream to read from, and optionally to write to, the file specified by the `File` argument.
    `RandomAccessFile` | `create(Path file)` Creates a random access file stream to read from, and optionally to write to, the file specified by the `File` argument.
    `RandomAccessFile` | `create(String file)` Creates a random access file stream to read from, and optionally to write to, the file specified by the `File` argument.
    `String` | `toString()`
    `static RandomAccessFileMode` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static RandomAccessFileMode[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### READ_ONLY

          public static final RandomAccessFileMode READ_ONLY

      Mode "r" opens for reading only.

    - #### READ_WRITE

          public static final RandomAccessFileMode READ_WRITE

      Mode "rw" opens for reading and writing.

    - #### READ_WRITE_SYNC_ALL

          public static final RandomAccessFileMode READ_WRITE_SYNC_ALL

      Mode "rws" opens 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

          public static final RandomAccessFileMode READ_WRITE_SYNC_CONTENT

      Mode "rwd" open 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.

  - ### Method Detail

    - #### values

          public static RandomAccessFileMode[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (RandomAccessFileMode c : RandomAccessFileMode.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static RandomAccessFileMode valueOf(String name)

      Returns 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

    - #### create

          public RandomAccessFile create(File file)
                                  throws FileNotFoundException

      Creates a random access file stream to read from, and optionally to write to, the file specified by the `File` argument.
      Parameters:
        `file` - the file object
      Returns:
        a random access file stream
      Throws:
        `FileNotFoundException` - See `RandomAccessFile(File, String)`.

    - #### create

          public RandomAccessFile create(Path file)
                                  throws FileNotFoundException

      Creates a random access file stream to read from, and optionally to write to, the file specified by the `File` argument.
      Parameters:
        `file` - the file object
      Returns:
        a random access file stream
      Throws:
        `FileNotFoundException` - See `RandomAccessFile(File, String)`.

    - #### create

          public RandomAccessFile create(String file)
                                  throws FileNotFoundException

      Creates a random access file stream to read from, and optionally to write to, the file specified by the `File` argument.
      Parameters:
        `file` - the file object
      Returns:
        a random access file stream
      Throws:
        `FileNotFoundException` - See `RandomAccessFile(File, String)`.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Enum<RandomAccessFileMode>`

Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.