|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.io.BinaryFile com.bbn.openmap.io.BinaryBufferedFile
public class BinaryBufferedFile
This class extends the BinaryFile class, doing buffered reads on the underlying input file. The buffer size is not modifiable after construction, and the buffer management isn't the greatest.
Field Summary |
---|
Fields inherited from class com.bbn.openmap.io.BinaryFile |
---|
MSBFirst |
Constructor Summary | |
---|---|
BinaryBufferedFile(java.io.File f)
Constructs a BinaryBufferedFile with a File |
|
BinaryBufferedFile(java.io.File f,
int buffersize)
Constructs a BinaryBufferedFile with a File and a buffer size |
|
BinaryBufferedFile(java.lang.String name)
Constructs a BinaryBufferedFile with a filename |
|
BinaryBufferedFile(java.lang.String name,
int buffersize)
Constructs a BinaryBufferedFile with a filename and a buffersize |
Method Summary | |
---|---|
long |
available()
Return how many bytes left to be read in the file. |
static BinaryBufferedFile |
create(java.lang.String name)
A simple factory method that lets you try to create something without having to really deal with failure. |
static BinaryBufferedFile |
create(java.lang.String name,
int buffersize)
A simple factory method that lets you try to create something without having to really deal with failure. |
void |
dispose()
Disposes the underlying file input, and releases some resources of the class. |
long |
getFilePointer()
Get the index of the next character to be read |
int |
read()
Read from the file. |
int |
read(byte[] b)
Read from the file. |
int |
read(byte[] b,
int off,
int len)
Read from the file |
byte[] |
readBytes(int howmany,
boolean allowless)
Read from the file. |
char |
readChar()
Reads and returns a single byte, cast to a char. |
java.lang.String |
readFixedLengthString(int length)
Reads length bytes and returns a string composed of the
bytes cast to chars. |
void |
readFloatArray(float[] vec,
int offset,
int len)
Reads an array of floats from the input. |
int |
readInteger()
Reads and returns a long. |
void |
readIntegerArray(int[] vec,
int offset,
int len)
Reads an array of integers. |
long |
readLong()
Reads and returns a long. |
short |
readShort()
Reads and returns a short. |
void |
readShortArray(short[] vec,
int offset,
int len)
Reads an array of shorts. |
int |
readUnsignedShort()
Reads and returns a integer from 2 bytes. |
void |
seek(long pos)
Set the index of the next character to be read. |
void |
setInputReader(InputReader reader)
Set the input reader used by the BinaryFile. |
long |
skipBytes(long n)
Skip over n bytes in the input file |
Methods inherited from class com.bbn.openmap.io.BinaryFile |
---|
addClosable, assertChar, byteOrder, byteOrder, close, closeClosable, exists, finalize, getInputReader, getName, length, readDouble, readFloat, readFloatArray, readFully, readShortData, readToDelimiter, readUnsigned, removeClosable, setJarInputReader |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinaryBufferedFile(java.io.File f, int buffersize) throws java.io.IOException
f
- the input filebuffersize
- the size to use for buffering reads
java.io.IOException
- pass-through errors from opening a BinaryFile with
fBinaryFile
public BinaryBufferedFile(java.io.File f) throws java.io.IOException
f
- the input file
java.io.IOException
- pass-through errors from opening a BinaryFile with
fBinaryFile
public BinaryBufferedFile(java.lang.String name, int buffersize) throws java.io.IOException
name
- the name/path of the input filebuffersize
- the size to use for buffering reads
java.io.IOException
- pass-through errors from opening a BinaryFile with
fBinaryFile
public BinaryBufferedFile(java.lang.String name) throws java.io.IOException
name
- the name/path of the input file
java.io.IOException
- pass-through errors from opening a BinaryFile with
fBinaryFile
Method Detail |
---|
public static BinaryBufferedFile create(java.lang.String name)
public static BinaryBufferedFile create(java.lang.String name, int buffersize)
public void setInputReader(InputReader reader)
setInputReader
in class BinaryFile
public long skipBytes(long n) throws java.io.IOException
BinaryFile
skipBytes
in class BinaryFile
n
- the number of bytes to skip
java.io.IOException
- Any IO errors that occur in skipping bytes in the
underlying filepublic long getFilePointer() throws java.io.IOException
BinaryFile
getFilePointer
in class BinaryFile
java.io.IOException
- Any IO errors that occur in accessing the
underlying filepublic void seek(long pos) throws java.io.IOException
BinaryFile
seek
in class BinaryFile
pos
- the position to seek to.
java.io.IOException
- Any IO Errors that occur in seeking the underlying
file.public long available() throws java.io.IOException
BinaryFile
available
in class BinaryFile
java.io.IOException
- Any IO errors encountered in accessing the filepublic void dispose() throws java.io.IOException
dispose
in class BinaryFile
java.io.IOException
- IO errors encountered in closing the filepublic int read() throws java.io.IOException
BinaryFile
read
in class BinaryFile
java.io.IOException
- Any IO errors encountered in reading from the filepublic int read(byte[] b, int off, int len) throws java.io.IOException
read
in class BinaryFile
b
- The byte array to read intooff
- the first array position to read intolen
- the number of bytes to read
java.io.IOException
- Any IO errors encountered in reading from the filepublic int read(byte[] b) throws java.io.IOException
BinaryFile
read
in class BinaryFile
b
- the byte array to read into. Equivalent to
read(b, 0, b.length)
java.io.IOException
- Any IO errors encountered in reading from the fileRandomAccessFile.read(byte[])
public byte[] readBytes(int howmany, boolean allowless) throws java.io.EOFException, FormatException
readBytes
in class BinaryFile
howmany
- the number of bytes to readallowless
- if we can return fewer bytes than requested
FormatException
- Any IO Exceptions, plus an end-of-file
encountered after reading some, but now enough, bytes when
allowless was false
java.io.EOFException
- Encountered an end-of-file while allowless was
false
, but NO bytes had been read.public char readChar() throws java.io.EOFException, FormatException
readChar
in class BinaryFile
java.io.EOFException
- the end-of-file has been reached, so no chars
where available
FormatException
- a rethrown IOExceptionpublic short readShort() throws java.io.EOFException, FormatException
readShort
in class BinaryFile
java.io.EOFException
- there were less than 2 bytes left in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the shortread(byte[])
public int readUnsignedShort() throws java.io.EOFException, FormatException
readUnsignedShort
in class BinaryFile
java.io.EOFException
- there were less than 2 bytes left in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the shortread(byte[])
public void readShortArray(short[] vec, int offset, int len) throws java.io.EOFException, FormatException
vec
- the array to write the shorts intooffset
- the first array index to write tolen
- the number of shorts to read
java.io.EOFException
- there were fewer bytes than needed in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the arraypublic int readInteger() throws java.io.EOFException, FormatException
readInteger
in class BinaryFile
java.io.EOFException
- there were less than 4 bytes left in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the integerBinaryFile.read(byte[])
public void readIntegerArray(int[] vec, int offset, int len) throws java.io.EOFException, FormatException
readIntegerArray
in class BinaryFile
java.io.EOFException
- there were fewer bytes than needed in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the arraypublic void readFloatArray(float[] vec, int offset, int len) throws java.io.EOFException, FormatException
readFloatArray
in class BinaryFile
vec
- the vector to read intooffset
- the first float read goes into vec[offset]len
- the number of floats to read from the stream
java.io.EOFException
- not enough bytes were left in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the integerpublic long readLong() throws java.io.EOFException, FormatException
readLong
in class BinaryFile
java.io.EOFException
- there were less than 8 bytes left in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the longread(byte[])
public java.lang.String readFixedLengthString(int length) throws java.io.EOFException, FormatException
length
bytes and returns a string composed of the
bytes cast to chars.
readFixedLengthString
in class BinaryFile
length
- the number of bytes to read into the string
java.io.EOFException
- there were less than length
bytes
left in the file
FormatException
- rethrow of IOExceptions encountered while
reading the bytes for the short
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |