public class RandomAccessDataFile extends java.lang.Object implements RandomAccessData
RandomAccessData implementation backed by a RandomAccessFile.| Constructor and Description |
|---|
RandomAccessDataFile(java.io.File file)
Create a new
RandomAccessDataFile backed by the specified file. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.io.File |
getFile()
Returns the underlying File.
|
java.io.InputStream |
getInputStream()
Returns an
InputStream that can be used to read the underlying data. |
long |
getSize()
Returns the size of the data.
|
RandomAccessData |
getSubsection(long offset,
long length)
Returns a new
RandomAccessData for a specific subsection of this data. |
byte[] |
read()
Reads all the data and returns it as a byte array.
|
byte[] |
read(long offset,
long length)
Reads the
length bytes of data starting at the given offset. |
public RandomAccessDataFile(java.io.File file)
RandomAccessDataFile backed by the specified file.file - the underlying filejava.lang.IllegalArgumentException - if the file is null or does not existpublic java.io.File getFile()
public java.io.InputStream getInputStream()
throws java.io.IOException
RandomAccessDataInputStream that can be used to read the underlying data. The
caller is responsible close the underlying stream.getInputStream in interface RandomAccessDatajava.io.IOException - if the stream cannot be openedpublic RandomAccessData getSubsection(long offset, long length)
RandomAccessDataRandomAccessData for a specific subsection of this data.getSubsection in interface RandomAccessDataoffset - the offset of the subsectionlength - the length of the subsectionpublic byte[] read()
throws java.io.IOException
RandomAccessDataread in interface RandomAccessDatajava.io.IOException - if the data cannot be readpublic byte[] read(long offset,
long length)
throws java.io.IOException
RandomAccessDatalength bytes of data starting at the given offset.read in interface RandomAccessDataoffset - the offset from which data should be readlength - the number of bytes to be readjava.io.IOException - if the data cannot be readjava.io.EOFException - if offset plus length is greater than the length of the file
or subsectionpublic long getSize()
RandomAccessDatagetSize in interface RandomAccessDatapublic void close()
throws java.io.IOException
java.io.IOException