org.apache.commons.io

## Class RandomAccessFiles

- java.lang.Object
- - org.apache.commons.io.RandomAccessFiles

-     public class RandomAccessFiles
      extends Object

  Works with `RandomAccessFile`.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `contentEquals(RandomAccessFile raf1, RandomAccessFile raf2)` Tests if two RandomAccessFile contents are equal.
    `static byte[]` | `read(RandomAccessFile input, long position, int length)` Reads a byte array starting at "position" for "length" bytes.
    `static RandomAccessFile` | `reset(RandomAccessFile raf)` Resets the given file to position 0.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### contentEquals

          public static boolean contentEquals(RandomAccessFile raf1,
                                              RandomAccessFile raf2)
                                       throws IOException

      Tests if two RandomAccessFile contents are equal.
      Parameters:
        `raf1` - A RandomAccessFile.
        `raf2` - Another RandomAccessFile.
      Returns:
        true if the contents of both RandomAccessFiles are equal, false otherwise.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### read

          public static byte[] read(RandomAccessFile input,
                                    long position,
                                    int length)
                             throws IOException

      Reads a byte array starting at "position" for "length" bytes.
      Parameters:
        `input` - The source RandomAccessFile.
        `position` - The offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
        `length` - How many bytes to read.
      Returns:
        a new byte array.
      Throws:
        `IOException` - If the first byte cannot be read for any reason other than end of file, or if the random access file has been closed, or if some other I/O error occurs.

    - #### reset

          public static RandomAccessFile reset(RandomAccessFile raf)
                                        throws IOException

      Resets the given file to position 0.
      Parameters:
        `raf` - The RandomAccessFile to reset.
      Returns:
        The given RandomAccessFile.
      Throws:
        `IOException` - If `pos` is less than `0` or if an I/O error occurs.