|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Reader java.io.FilterReader org.sadun.util.PushbackReader
A reader that allows to push back an arbitrary number of characters.
It also offers some commonly used lookahead comparison operations (based on reading/unreading characters). These should really be in a separate class in the future.
Field Summary |
Fields inherited from class java.io.FilterReader |
in |
Fields inherited from class java.io.Reader |
lock |
Constructor Summary | |
PushbackReader(java.io.Reader r)
Create a pushback reader over the given source of characters, allowing to push |
Method Summary | |
static void |
main(java.lang.String[] args)
|
boolean |
nextEquals(java.lang.String s)
Looks ahead to check whether the next characters on the stream equal the given String. |
boolean |
nextEquals(java.lang.String s,
boolean unreadIfTrue)
Looks ahead to check whether the next characters on the stream equal the given String. |
boolean |
nextEqualsIgnoreCase(java.lang.String s,
boolean unreadIfTrue)
Looks ahead to check whether the next characters on the stream equal the given String (ignoring letter case). |
int |
read()
Read the next character. |
java.lang.String |
readNext(int n)
Attempt to read the next n characters in the stream, then unread them. |
void |
unread(int c)
Unread the given character. |
Methods inherited from class java.io.FilterReader |
close, mark, markSupported, read, ready, reset, skip |
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 PushbackReader(java.io.Reader r)
r
- the source of charactersMethod Detail |
public int read() throws java.io.IOException
java.io.IOException
- if there is a problem reading the stream.public void unread(int c) throws java.io.IOException
read()
operation.
c
- the charater to unread
java.io.IOException
- if there is a problem unreading the character.public java.lang.String readNext(int n) throws java.io.IOException
n
- the number of character to read.
java.io.IOException
- in case of problems reading the streampublic boolean nextEquals(java.lang.String s) throws java.io.IOException
s
- the string to compare
java.io.IOException
- in case of problems reading the streampublic boolean nextEquals(java.lang.String s, boolean unreadIfTrue) throws java.io.IOException
s
- the string to compareunreadIfTrue
- if false and the comparison is successful, the
stream position will be after the successfully compared
string. Otherwise, it will be unchanged.
java.io.IOException
- in case of problems reading the streampublic boolean nextEqualsIgnoreCase(java.lang.String s, boolean unreadIfTrue) throws java.io.IOException
s
- the string to compareunreadIfTrue
- if false and the comparison is successful, the
stream position will be after the successfully compared
string. Otherwise, it will be unchanged.
java.io.IOException
- in case of problems reading the streampublic static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |