Package org.apache.commons.io
Class RandomAccessFiles
java.lang.Object
org.apache.commons.io.RandomAccessFiles
Works with
RandomAccessFile
.- Since:
- 2.13.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Constructor Details
-
RandomAccessFiles
Deprecated.TODO Make private in 3.0.Make private in 3.0.
-
-
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
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
Resets the given file to position 0.- Parameters:
raf
- The RandomAccessFile to reset.- Returns:
- The given RandomAccessFile.
- Throws:
IOException
- Ifpos
is less than0
or if an I/O error occurs.- Since:
- 2.15.0
-