|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Reader | +--java.io.FilterReader | +--java.io.PushbackReader | +--lava.io.UnlimitedPushbackReader
"Pushbackable" input stream with no pushback limit.
Details: This class is similar to java.io.PushbackReader
, except that no limit is imposed on the number of characters that can be pushed back. Additionally, the unread methods can process either characters or whole strings.
Fields inherited from class java.io.FilterReader |
in |
Fields inherited from class java.io.Reader |
lock |
Constructor Summary | |
UnlimitedPushbackReader(java.io.Reader reader)
Converts a Reader to an UnlimitedPushbackReader . |
Method Summary | |
void |
close()
|
boolean |
eof()
Tells if the end-of-stream has been reached. |
void |
mark(int read_ahead_limit)
Marks the present position. |
int |
peek()
Previews the next character. |
int |
read()
Reads the next character. |
int |
read(char[] dest)
|
int |
read(char[] dest,
int off,
int len)
Reads a block of characters. |
void |
reset()
Restores this stream to the previously marked state. |
void |
unread(char[] src)
|
void |
unread(char[] src,
int off,
int len)
|
void |
unread(int c)
Pushes a character back to the stream. |
void |
unread(java.lang.String s)
Pushes a String back to the stream. |
Methods inherited from class java.io.PushbackReader |
markSupported, ready |
Methods inherited from class java.io.FilterReader |
skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UnlimitedPushbackReader(java.io.Reader reader)
Reader
to an UnlimitedPushbackReader
.reader
- the Reader
Method Detail |
public int read() throws java.io.IOException
Details: read
reads the next character from the stream and returns it. If the end-of-stream has been reached, -1 is returned.
read
in class java.io.PushbackReader
java.io.IOException
- if an I/O error occurspublic final int read(char[] dest) throws java.io.IOException
read
in class java.io.Reader
public int read(char[] dest, int off, int len) throws java.io.IOException
Details: This method reads a block of characters from this stream, filling dest
, the supplied destination buffer. len
characters are written into dest
begining at offset off
. If no characters can be read before encountering the end-of-stream, -1 is returned. Otherwise, the number of characters read and stored in buff
is returned. Note that if end-of-stream is reached while filling the buffer, this value may be less than len
.
read
in class java.io.PushbackReader
dest
- the destination bufferoff
- offset into destlen
- number of characters to readjava.io.IOException
- if an I/O error occurspublic int peek() throws java.io.IOException
Details: peek
read
s and unread
s the next character, and then returns its value.
Calls: read()
, unread(int)
java.io.IOException
- if an I/O error occurspublic void unread(int c) throws java.io.IOException
Details: unread
pushes a character back onto the stream. Subsequent calls to read
will retrieve it. Unreading an EOF is allowed and has no effect.
unread
in class java.io.PushbackReader
c
- the characterpublic final void unread(char[] src) throws java.io.IOException
unread
in class java.io.PushbackReader
public void unread(char[] src, int off, int len) throws java.io.IOException
unread
in class java.io.PushbackReader
public void unread(java.lang.String s) throws java.io.IOException
Details: unread
pushes a String back onto the stream. Subsequent calls to read
will retrieve its characters. Unreading null
is allowed and has no effect.
s
- the String
public void mark(int read_ahead_limit) throws java.io.IOException
Details: mark
marks the present position in this stream. Subsequent calls to reset
will attempt to restore the stream to the state it was at when mark
was last called. There is a limit on how many characters can be read (read_ahead_limit
), after calling mark
, before calls to reset
are no longer guaranteed to be successful. Not all streams support mark
. This stream supports mark
if the base stream supports mark
.
mark
in class java.io.PushbackReader
read_ahead_limit
- number of characters that can be read after mark
before reset
-ability is compromisedjava.io.IOException
- if the stream cannot be markedpublic void reset() throws java.io.IOException
Details: reset
attempts to restore the stream to the state it was in during the most recent call to mark
. If mark
has not been previously called, then reset
will attempt to reset this stream in a manner that is appropriate for this particular type of stream. Not all streams support reset
. This stream supports reset
if the base stream supports reset
.
reset
in class java.io.PushbackReader
java.io.IOException
- if the stream cannot be resetpublic boolean eof() throws java.io.IOException
Details: eof
calls peek
to see if another character is available in the stream. If the end-of-stream has been reached, peek
returns true
, otherwise false
.
Technically, this method checks for end-of-stream, not end-of-file, since the base stream may not originate from a file. This method is named "eof" for traditional reasons.
Calls: peek()
true
iff the end-of-stream has been reachedjava.io.IOException
- if an I/O error occurspublic void close() throws java.io.IOException
close
in class java.io.PushbackReader
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |