Package org.apache.commons.io

# Class RandomAccessFiles

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

public class RandomAccessFiles extends Object
Works with `RandomAccessFile`.

Since:
  2.13.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RandomAccessFiles()`

- ## Method Summary

  Modifier and Type
  Method
  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`

- ## Constructor Details

  - ### RandomAccessFiles

    public RandomAccessFiles()

- ## Method Details

  - ### 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.
    Since:
      2.15.0

  - ### 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.
    Since:
      2.15.0