|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.io.StreamInputReader
public abstract class StreamInputReader
An Abstract InputReader to handle reading data from streams, where seeking to a place in the file in front of the current pointer involves closing the stream, and re-seeking from the beginning.
InputReader
,
BinaryFile
Field Summary | |
---|---|
protected java.io.InputStream |
inputStream
The underlying data input stream, for resource files. |
protected long |
inputStreamCount
Keep track of how many bytes have been read when using the DataInputStream to read the file. |
protected java.lang.String |
name
The source name. |
Constructor Summary | |
---|---|
StreamInputReader()
|
Method Summary | |
---|---|
long |
available()
Return how many bytes the input stream thinks are available. |
void |
close()
Closes the underlying file |
protected int |
count(int add)
Add the number of bytes to the inputStreamCount. |
long |
getFilePointer()
Get the index of the next character to be read |
java.lang.String |
getName()
Get the name of the source. |
long |
length()
Return how many bytes the input stream thinks make up the file. |
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. |
protected void |
reopen()
Reset the DataInputStream to the beginning, by closing the current connection and reopening it. |
void |
seek(long pos)
Set the index of the next character to be read. |
long |
skipBytes(long n)
Skip over n bytes in the input file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.InputStream inputStream
protected long inputStreamCount
protected java.lang.String name
Constructor Detail |
---|
public StreamInputReader()
Method Detail |
---|
public java.lang.String getName()
InputReader
getName
in interface InputReader
protected int count(int add)
protected void reopen() throws java.io.IOException
java.io.IOException
public long skipBytes(long n) throws java.io.IOException
skipBytes
in interface InputReader
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
getFilePointer
in interface InputReader
java.io.IOException
- Any IO errors that occur in accessing the
underlying filepublic void seek(long pos) throws java.io.IOException
seek
in interface InputReader
pos
- the position to seek to.
java.io.IOException
- Any IO Errors that occur in seeking the underlying
file.public long length() throws java.io.IOException
length
in interface InputReader
java.io.IOException
- Any IO errors encountered in accessing the filepublic long available() throws java.io.IOException
available
in interface InputReader
java.io.IOException
- Any IO errors encountered in accessing the filepublic void close() throws java.io.IOException
close
in interface InputReader
java.io.IOException
- Any IO errors encountered in accessing the filepublic int read() throws java.io.IOException
read
in interface InputReader
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 interface InputReader
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
read
in interface InputReader
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 interface InputReader
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |