|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--AsciiDatabase.AsciiReader
A fully buffered, random access reader capable of reading both fixed sized blocks and carrage return terminated lines. Also, can read from either normal uncompressed files, or GZIP compressed files.
| Field Summary | |
private byte[] |
buffer
Buffer used to improve performance of small reads. |
static int |
buffersize
Default buffer size for uncompressed files. |
private File |
file
Open file. |
private RandomAccessFile |
stream
Stream used for uncompressed file. |
private long |
streampos
Current stream position. |
private int |
validlength
Length of valid data in buffer. |
private int |
validoffset
Offset of next valid data in buffer. |
private GZIPInputStream |
zstream
Stream used for compressed file. |
static int |
zstreambuffer
Default buffer size for compressed files. |
| Constructor Summary | |
AsciiReader(String filename)
Open an uncompressed file by name. |
|
AsciiReader(String filename,
boolean gzip)
Open an uncompressed or compressed file by name. |
|
| Method Summary | |
void |
close()
Close the data file. |
protected void |
finalize()
Close the data file. |
long |
getFilePointer()
Return the current file pointer position. |
long |
length()
Return the length of the file. |
void |
pushBack()
Push back the last byte read so it can be read again. |
int |
read()
Read a byte from the file. |
int |
read(byte[] b)
Read data from the file. |
int |
read(byte[] b,
int off,
int len)
Read data from the file. |
String |
readLine()
Read a single line of an ascii file. |
int |
readToEOL(byte[] b)
Read until the end of line is reached. |
int |
readToEOL(byte[] b,
int off,
int len)
Read until the end of line is reached. |
void |
seek(long off)
Seek to an arbitrary offset within the file. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int buffersize
public static final int zstreambuffer
private File file
private RandomAccessFile stream
private GZIPInputStream zstream
private byte[] buffer
private int validoffset
private int validlength
private long streampos
| Constructor Detail |
public AsciiReader(String filename)
throws IOException
filename - name of file to openIOException - if an error occurs openning the file
public AsciiReader(String filename,
boolean gzip)
throws IOException
filename - name of file to opengzip - flag to indicate if the file is GZIP compressedIOException - if an error occurs openning the file| Method Detail |
public void close()
protected void finalize()
finalize in class Object
public void pushBack()
throws IOException
IOException - if the byte cannot be pushed back
public final int read()
throws IOException
IOException - if an error occurs reading the file
public int readToEOL(byte[] b,
int off,
int len)
throws IOException
b - buffer where data should be placedoff - offset within buffer where data should golen - maximum number of to be placed in bufferIOException - if an error occurs reading the file
public final int readToEOL(byte[] b)
throws IOException
b - buffer where data should be placedIOException - if an error occurs reading the file
public int read(byte[] b,
int off,
int len)
throws IOException
b - buffer where data should be placedoff - offset within buffer where data should golen - maximum number of to be placed in bufferIOException - if an error occurs reading the file
public final int read(byte[] b)
throws IOException
b - buffer where data should be placedIOException - if an error occurs reading the file
public long getFilePointer()
throws IOException
IOException - if an error occurspublic long length()
public void seek(long off)
throws IOException
off - offset to seek toIOException - if an error occurs
public String readLine()
throws IOException
IOException - if an error occurs openning the file
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||