Class RandomAccessFiles


  • public class RandomAccessFiles
    extends java.lang.Object
    Works with RandomAccessFile.
    Since:
    2.13.0
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomAccessFiles()
      Deprecated.
      TODO Make private in 3.0.
    • Method Summary

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

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RandomAccessFiles

        @Deprecated
        public RandomAccessFiles()
        Deprecated.
        TODO Make private in 3.0.
        Make private in 3.0.
    • Method Detail

      • contentEquals

        public static boolean contentEquals​(java.io.RandomAccessFile raf1,
                                            java.io.RandomAccessFile raf2)
                                     throws java.io.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:
        java.io.IOException - if an I/O error occurs.
        Since:
        2.15.0
      • read

        public static byte[] read​(java.io.RandomAccessFile input,
                                  long position,
                                  int length)
                           throws java.io.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:
        java.io.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 java.io.RandomAccessFile reset​(java.io.RandomAccessFile raf)
                                              throws java.io.IOException
        Resets the given file to position 0.
        Parameters:
        raf - The RandomAccessFile to reset.
        Returns:
        The given RandomAccessFile.
        Throws:
        java.io.IOException - If pos is less than 0 or if an I/O error occurs.
        Since:
        2.15.0