public class ByteWiseFileAccessor
extends java.lang.Object
implements java.io.Closeable
Constructor and Description |
---|
ByteWiseFileAccessor(java.io.File file,
long offset,
int length,
long records)
Constructs a
ByteWiseFileAccessor object which maps a region of a data file into
memory. |
ByteWiseFileAccessor(java.net.URL url,
long offset,
int length,
long records)
Constructs a
ByteWiseFileAccessor object which maps a region of a data file into
memory. |
ByteWiseFileAccessor(java.net.URL url,
long offset,
int length,
long records,
boolean checkSize) |
ByteWiseFileAccessor(java.net.URL url,
long offset,
int length,
long records,
boolean checkSize,
java.io.RandomAccessFile raf)
Constructs a
ByteWiseFileAccessor object which maps a region of a data file into
memory. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
getCurrentPosition() |
java.io.RandomAccessFile |
getRandomAccessFile() |
long |
getTotalBytesRead() |
long |
getTotalFileContentSize() |
boolean |
hasRemaining()
Checks to see if the buffer can still be read.
|
void |
mark()
Marks the buffer.
|
byte |
readByte()
Reads a byte from the buffer.
|
byte[] |
readRecordBytes(long recordNum,
int offset,
int length)
Reads
length bytes of data from a specified record at the given offset. |
void |
reset()
Resets the buffer.
|
public ByteWiseFileAccessor(java.io.File file, long offset, int length, long records) throws java.io.FileNotFoundException, java.io.IOException, InvalidTableException
ByteWiseFileAccessor
object which maps a region of a data file into
memory.file
- the data fileoffset
- the offset within the data filelength
- the record length in bytesrecords
- the number of recordsjava.io.FileNotFoundException
- If file
does not exist, is a directory rather than a
regular file, or for some other reason cannot be opened for readingjava.io.IOException
- If an I/O error occursInvalidTableException
MissingDataException
java.lang.IllegalArgumentException
public ByteWiseFileAccessor(java.net.URL url, long offset, int length, long records) throws java.io.FileNotFoundException, java.io.IOException, InvalidTableException
ByteWiseFileAccessor
object which maps a region of a data file into
memory.url
- the data fileoffset
- the offset within the data filelength
- the record length in bytesrecords
- the number of recordsjava.io.FileNotFoundException
- If file
does not exist, is a directory rather than a
regular file, or for some other reason cannot be opened for readingjava.io.IOException
- If an I/O error occursInvalidTableException
MissingDataException
java.lang.IllegalArgumentException
public ByteWiseFileAccessor(java.net.URL url, long offset, int length, long records, boolean checkSize) throws java.io.FileNotFoundException, java.io.IOException, InvalidTableException
java.io.FileNotFoundException
java.io.IOException
InvalidTableException
public ByteWiseFileAccessor(java.net.URL url, long offset, int length, long records, boolean checkSize, java.io.RandomAccessFile raf) throws java.io.FileNotFoundException, java.io.IOException, InvalidTableException
ByteWiseFileAccessor
object which maps a region of a data file into
memory.url
- the data fileoffset
- the offset within the data filelength
- the record length in bytesrecords
- the number of recordscheckSize
- check that the size of the data file is equal to the size of the table (length
* records) + offset.java.io.FileNotFoundException
- If file
does not exist, is a directory rather than a
regular file, or for some other reason cannot be opened for readingjava.io.IOException
- If an I/O error occursInvalidTableException
MissingDataException
public byte[] readRecordBytes(long recordNum, int offset, int length)
length
bytes of data from a specified record at the given offset.recordNum
- the record number to read bytes from (1-relative)offset
- an offset within the recordlength
- the number of bytes to read from the recordpublic byte readByte()
public void mark()
public void reset()
public boolean hasRemaining()
public long getCurrentPosition()
public long getTotalFileContentSize()
public long getTotalBytesRead()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public java.io.RandomAccessFile getRandomAccessFile()
Copyright © 2023 Planetary Data System. All rights reserved.