public abstract class StreamInputReader extends java.lang.Object implements InputReader
InputReader
,
BinaryFile
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
StreamInputReader() |
Modifier and Type | Method and Description |
---|---|
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
|
protected java.io.InputStream inputStream
protected long inputStreamCount
protected java.lang.String name
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 skipjava.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 readjava.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 requestedFormatException
- 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.Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details