|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Reader
dd.util.DelimReader
Reader that stops at user-defined delimeters. This reader serves as a wrapper for an existing character stream. It simulates the underlying reader, but when the simulated end-of-input marker is encountered, the reader returns end of input without closing the underlying Reader. This allows an input file to be read in chunks. After this reader reaches the marker, the underlying stream will be positioned immediately after that marker.
Example input file:
This is a text file to be used with DelimReader, it will keep reading until the synthetic EOF is reached __EOF__ This text will never be encountered by the DelimReader, but will be the next thing read from the underlying Reader.
Reader r = new DelimReader(input, "__EOF__");
Field Summary |
Fields inherited from class java.io.Reader |
lock |
Constructor Summary | |
DelimReader(java.io.Reader in,
java.lang.String eofMarker)
Creates a new reader using the underlying stream and synthetic EOF marker. |
Method Summary | |
void |
close()
Close does nothing on this stream. |
static void |
main(java.lang.String[] args)
Tests the DelimReader. |
int |
read()
Reads the next character of input. |
int |
read(char[] cbuf,
int off,
int len)
Reads characters into the buffer provided. |
Methods inherited from class java.io.Reader |
mark, markSupported, read, ready, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DelimReader(java.io.Reader in, java.lang.String eofMarker)
eofMarker
is encountered. Once this is encountered, the
DelimReader will pretend to be at the end of input.
in
- character stream from which to read inputeofMarker
- text to trigger the end of input chunkMethod Detail |
public void close()
public int read() throws java.io.IOException
eofMarker
.
Otherwise, this method returns the next character of input.
java.io.IOException
- if an error occurs reading from the underlying
stream.public int read(char[] cbuf, int off, int len) throws java.io.IOException
cbuf
- buffer into which input should be writtenoff
- offset into the buffer to write datalen
- maximum number of bytes to write
java.io.IOException
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- command line arguments, the first being the file to read,
the second being the delimeter
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |