is new.
java.lang.Objectjava.io.Reader
java.io.StringReader
All Implemented Interfaces:
Closeable
,
Readable
A character stream whose source is a string.
| Field Summary |
|---|
| Fields inherited from class java.io. Reader |
|---|
| lock |
| Constructor Summary | |
|---|---|
|
StringReader
(
String
s) Create a new string reader. |
|
| Method Summary | |
|---|---|
| void |
close
() Close the stream. |
| void |
mark
(int readAheadLimit) Mark the present position in the stream. |
| boolean |
markSupported
() Tell whether this stream supports the mark() operation, which it does. |
| int |
read
() Read a single character. |
| int |
read
(char[] cbuf, int off, int len) Read characters into a portion of an array. |
| boolean |
ready
() Tell whether this stream is ready to be read. |
| void |
reset
() Reset the stream to the most recent mark, or to the beginning of the string if it has never been marked. |
| long |
skip
(long ns)
Skips the specified number of characters in the stream.
|
| Methods inherited from class java.io. Reader |
|---|
read
,
read
|
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
| Constructor Detail |
|---|
public StringReader(String s)
| Method Detail |
|---|
public int read()
throws IOException
public int read(char[] cbuf,
int off,
int len)
throws IOException
public long skip(long ns)
throws IOException
Skips the specified number of characters in the stream. Returns the number of characters that were skipped.
The ns parameter may be negative, even though the the skip method of the
Reader
superclass throws an exception in this case. Negative values of ns cause the stream to skip backwards. Negative return values indicate a skip backwards. It is not possible to skip backwards past the beginning of the string.
If the entire string has been read or skipped, then this method has no effect and always returns 0.
public boolean ready()
throws IOException
public boolean markSupported()
public void mark(int readAheadLimit)
throws IOException
public void reset()
throws IOException
public void close()
close
in interface
Closeable
Specified by: