public class FileInputReader extends java.lang.Object implements InputReader
RandomAccessFile
,
InputReader
,
BinaryFile
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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
|
protected java.io.RandomAccessFile inputFile
protected java.lang.String name
protected java.lang.String absolutePath
public FileInputReader(java.io.File f) throws java.io.IOException
f
- the file to be opened for readingjava.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
public java.lang.String getName()
getName
in interface InputReader
public java.lang.String getAbsolutePath()
protected java.io.RandomAccessFile init(java.io.File f) throws java.io.IOException
f
- a java.io.Filejava.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 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 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 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