|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bbn.openmap.io.FileInputReader
public class 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.lang.String |
absolutePath
Needed for reopening files that have been closed. |
protected java.io.RandomAccessFile |
inputFile
The underlying file input |
protected java.lang.String |
name
Needed for input reader interface. |
| 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 |
java.lang.String |
getAbsolutePath()
|
long |
getFilePointer()
Get the index of the next character to be read |
java.io.RandomAccessFile |
getInputFile()
Get the RandomAccessFile, for querying 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
protected java.lang.String absolutePath
| 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 InputReaderpublic java.lang.String getAbsolutePath()
protected java.io.RandomAccessFile init(java.io.File f)
throws java.io.IOException
f - a java.io.File
java.io.IOExceptionpublic 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 InputReadern - the number of bytes to skip
java.io.IOException - Any IO errors that occur in skipping bytes in the
underlying file
public long getFilePointer()
throws java.io.IOException
getFilePointer in interface InputReaderjava.io.IOException - Any IO errors that occur in accessing the
underlying file
public void seek(long pos)
throws java.io.IOException
seek in interface InputReaderpos - 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 InputReaderjava.io.IOException - Any IO errors that occur in accessing the
underlying file.
public long available()
throws java.io.IOException
available in interface InputReaderjava.io.IOException - Any IO errors encountered in accessing the file
public void close()
throws java.io.IOException
close in interface InputReaderjava.io.IOException - Any IO errors encountered in accessing the file
public int read()
throws java.io.IOException
read in interface InputReaderjava.io.IOException - Any IO errors encountered in reading from the file
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in interface InputReaderb - 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 file
public int read(byte[] b)
throws java.io.IOException
read in interface InputReaderb - 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 InputReaderhowmany - 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 | |||||||||