public class LookAheadReader extends Reader
LookAheadStream
Constructor and Description |
---|
LookAheadReader(Reader parent,
String endMarker)
Creates an instance of a LookAheadReader that will read from the
given stream until the end marker is found.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the current stream, by setting the end of file
flag equal to true.
|
static void |
main(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.
|
public LookAheadReader(Reader parent, String endMarker)
parent
- Reader the stream used for reading the input/endMarker
- String the marker which signifies the end of the stream.public int read() throws IOException
read
in class Reader
IOException
- if there is any error while reading from the stream.public int read(char[] cbuf) throws IOException
read
in class Reader
cbuf
- cbuf - Destination bufferIOException
- If an I/O error occurspublic int read(char[] cbuf, int offset, int len) throws IOException
read
in class Reader
cbuf
- Destination bufferoffset
- Offset at which to start storing characterslen
- Maximum number of characters to readIOException
- If an I/O error occurspublic void reset() throws IOException
reset
in class Reader
IOException
- thrown if ParentStream.reset();public long skip(long n) throws IOException
skip
in class Reader
n
- long the number of characters to skip.IOException
- if there is any error while
reading from the stream.public boolean ready() throws IOException
ready
in class Reader
IOException
- if there is any error while
reading from the stream.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Reader
IOException
public boolean markSupported()
markSupported
in class Reader
public void mark(int x) throws IOException
mark
in class Reader
IOException
public static void main(String[] args)
args
- the command line arguments, which should contain
the name of a file with documents delimited by
the second command line argument.Terrier Information Retrieval Platform 5.1. Copyright © 2004-2019, University of Glasgow