Package org.apache.commons.io
Class RandomAccessFiles
- java.lang.Object
-
- org.apache.commons.io.RandomAccessFiles
-
public class RandomAccessFiles extends java.lang.Object
Works withRandomAccessFile
.- 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.
-
-
-
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
- Ifpos
is less than0
or if an I/O error occurs.- Since:
- 2.15.0
-
-