|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bbn.openmap.io.FileInputReader
This class wraps a java.io.RandomAccessFile to allow us to choose the byte-order of the underlying file. It has a user-settable byte-ordering, which is then used to properly implement the various multibyte reading members. Used for reading local files.
RandomAccessFile
,
InputReader
,
BinaryFile
Field Summary | |
protected java.io.RandomAccessFile |
inputFile
The underlying file input |
protected java.lang.String |
name
|
Constructor Summary | |
FileInputReader(java.io.File f)
Constructs a new BinaryFile with the specified file as the input. |
|
FileInputReader(java.lang.String f)
Constructs a new BinaryFile with the specified file as the input. |
Method Summary | |
long |
available()
Return how many bytes left to be read in the file. |
java.io.RandomAccessFile |
checkInputFile()
|
void |
close()
Closes the underlying file |
long |
getFilePointer()
Get the index of the next character to be read |
java.io.RandomAccessFile |
getInputFile()
Get the RandomAccessFile, for quering purposes only. |
java.lang.String |
getName()
Get the file name. |
protected java.io.RandomAccessFile |
init(java.io.File f)
Initialize the underlying RandomAccessFile. |
long |
length()
Local files only. |
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. |
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.RandomAccessFile inputFile
protected java.lang.String name
Constructor Detail |
public FileInputReader(java.io.File f) throws java.io.IOException
f
- the file to be opened for reading
java.io.IOException
- pass-through errors from opening a
RandomAccessFile with fRandomAccessFile
public FileInputReader(java.lang.String f) throws java.io.IOException
f
- the path to the file to be opened for reading.
java.io.IOException
- pass-through errors from opening a
RandomAccessFile with fRandomAccessFile
Method Detail |
public java.lang.String getName()
getName
in interface InputReader
protected java.io.RandomAccessFile init(java.io.File f) throws java.io.IOException
f
- a java.io.File
java.io.IOException
public java.io.RandomAccessFile getInputFile()
public java.io.RandomAccessFile checkInputFile() 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 that occur in accessing the
underlying file.public 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. Equivelent 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 |