|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Reader org.terrier.utility.LookAheadReader
public class LookAheadReader
Implements a Reader, that encapsulates another stream, but only upto the point that a pre-defined end marker in the stream is identified. The Reader will then become endOfFile, and refuse to return any more characters from the stream. Suppose that we create an instance of a LookAheadReader with the end marker END. For the following input: a b c d END e f g... the LookAheadReader will stop after reading the string END. Note that the end marker will be missing from the parent stream.
LookAheadStream
Field Summary |
---|
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
LookAheadReader(java.io.Reader parent,
java.lang.String endMarker)
Creates an instance of a LookAheadReader that will read from the given stream until the end marker is found. |
Method Summary | |
---|---|
void |
close()
Closes the current stream, by setting the end of file flag equal to true. |
static void |
main(java.lang.String[] args)
A testing method for |
void |
mark(int x)
This method is not implemented. |
boolean |
markSupported()
Support for marking is not implemented. |
int |
read()
Read a character from the parent stream, first checking that it doesnt form part of the end marker. |
int |
read(char[] cbuf)
Read characters into an array. |
int |
read(char[] cbuf,
int offset,
int len)
Read characters into a portion of an array. |
boolean |
ready()
Indicates whether there are more characters available to read from the stream. |
void |
reset()
Reset the stream. |
long |
skip(long n)
Skips n characters from the stream. |
Methods inherited from class java.io.Reader |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LookAheadReader(java.io.Reader parent, java.lang.String endMarker)
parent
- Reader the stream used for reading the input/endMarker
- String the marker which signifies the end of the stream.Method Detail |
---|
public int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
- if there is any error while reading from the stream.public int read(char[] cbuf) throws java.io.IOException
read
in class java.io.Reader
cbuf
- cbuf - Destination buffer
java.io.IOException
- If an I/O error occurspublic int read(char[] cbuf, int offset, int len) throws java.io.IOException
read
in class java.io.Reader
cbuf
- Destination bufferoffset
- Offset at which to start storing characterslen
- Maximum number of characters to read
java.io.IOException
- If an I/O error occurspublic void reset() throws java.io.IOException
reset
in class java.io.Reader
java.io.IOException
- thrown if ParentStream.reset();public long skip(long n) throws java.io.IOException
skip
in class java.io.Reader
n
- long the number of characters to skip.
java.io.IOException
- if there is any error while
reading from the stream.public boolean ready() throws java.io.IOException
ready
in class java.io.Reader
java.io.IOException
- if there is any error while
reading from the stream.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.Reader
java.io.IOException
public boolean markSupported()
markSupported
in class java.io.Reader
public void mark(int x) throws java.io.IOException
mark
in class java.io.Reader
java.io.IOException
public static void main(java.lang.String[] args)
args
- the command line arguments, which should contain
the name of a file with documents delimited by
the second command line argument.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |