API Note
Reader#of(CharSequence) provides a method to read from any
CharSequence that may be more efficient than StringReader.
| Modifier and Type | Field and Description |
|---|---|
| private final Reader |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract java. Implements java. Closes the stream and releases any system resources associated with it. |
| public void | mark(int
Limit on the number of characters that may be
read while still preserving the mark. Because
the stream's input comes from a string, there
is no actual limit, so this argument must not
be negative, but is otherwise ignored. readAheadLimit)Overrides java. Marks the present position in the stream. |
| public boolean | markSupported()
Overrides java. Tells whether this stream supports the mark() operation, which it does. |
| public int | Returns: The character read, or -1 if the end of the stream has been reachedOverrides java. Reads a single character. |
| public int | read(char[] cbuf, int off, int len)
Implements abstract java. Reads characters into a portion of an array. |
| public boolean | Returns: True if the next read() is guaranteed not to block for inputOverrides java. Tells whether this stream is ready to be read. |
| public void | reset()
Overrides java. Resets the stream to the most recent mark, or to the beginning of the string if it has never been marked. |
| public long |
| r | back to summary |
|---|---|
| private final Reader r | |
| StringReader | back to summary |
|---|---|
| public StringReader(String s) Creates a new string reader.
| |
| close | back to summary |
|---|---|
| public void close() Implements abstract java. Implements java. Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), or reset() invocations will throw an IOException. Closing a previously closed stream has no effect. This method will block while there is another thread blocking on the reader. | |
| mark | back to summary |
|---|---|
| public void mark(int readAheadLimit) throws IOException Overrides java. Marks the present position in the stream. Subsequent calls to reset() will reposition the stream to this point.
| |
| markSupported | back to summary |
|---|---|
| public boolean markSupported() Overrides java. Tells whether this stream supports the mark() operation, which it does. | |
| read | back to summary |
|---|---|
| public int read() throws IOException Overrides java. Reads a single character.
| |
| read | back to summary |
|---|---|
| public int read(char[] cbuf, int off, int len) throws IOException Implements abstract java. Reads characters into a portion of an array. If
| |
| ready | back to summary |
|---|---|
| public boolean ready() throws IOException Overrides java. Tells whether this stream is ready to be read.
| |
| reset | back to summary |
|---|---|
| public void reset() throws IOException Overrides java. Resets the stream to the most recent mark, or to the beginning of the string if it has never been marked.
| |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Skips characters. If the stream is already at its end before this method is invoked, then no characters are skipped and zero is returned. The If the entire string has been read or skipped, then this method has
no effect and always returns
| |