java.lang.Object | ||
↳ | java.io.Reader | |
↳ | java.io.StringReader |
A specialized Reader
that reads characters from a String
in
a sequential manner.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.io.Reader
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a new
StringReader with str as source. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Closes this reader.
| |||||||||||
Sets a mark position in this reader.
| |||||||||||
Indicates whether this reader supports the
mark() and reset() methods. | |||||||||||
Reads a single character from the source string and returns it as an
integer with the two higher-order bytes set to 0.
| |||||||||||
Reads at most
len characters from the source string and stores
them at offset in the character array buf . | |||||||||||
Indicates whether this reader is ready to be read without blocking.
| |||||||||||
Resets this reader's position to the last
mark() location. | |||||||||||
Moves
ns characters in the source string. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.Reader
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
From interface java.lang.Readable
|
Construct a new StringReader
with str
as source. The size
of the reader is set to the length()
of the string and the Object
to synchronize access through is set to str
.
str | the source string for this reader. |
---|
Closes this reader. Once it is closed, read operations on this reader
will throw an IOException
. Only the first invocation of this
method has any effect.
Sets a mark position in this reader. The parameter readLimit
is
ignored for this class. Calling reset()
will reposition the
reader back to the marked position.
readLimit | ignored for StringReader instances. |
---|
IllegalArgumentException | if readLimit < 0 . |
---|---|
IOException | if this reader is closed. |
Indicates whether this reader supports the mark()
and reset()
methods. This implementation returns true
.
true
.
Reads a single character from the source string and returns it as an integer with the two higher-order bytes set to 0. Returns -1 if the end of the source string has been reached.
IOException | if this reader is closed. |
---|
Reads at most len
characters from the source string and stores
them at offset
in the character array buf
. Returns the
number of characters actually read or -1 if the end of the source string
has been reached.
buf | the character array to store the characters read. |
---|---|
offset | the initial position in buffer to store the characters
read from this reader. |
len | the maximum number of characters to read. |
IndexOutOfBoundsException | if offset < 0 or len < 0 , or if
offset + len is greater than the size of buf . |
---|---|
IOException | if this reader is closed. |
Indicates whether this reader is ready to be read without blocking. This
implementation always returns true
.
true
.IOException | if this reader is closed. |
---|
Resets this reader's position to the last mark()
location.
Invocations of read()
and skip()
will occur from this new
location. If this reader has not been marked, it is reset to the
beginning of the source string.
IOException | if this reader is closed. |
---|
Moves ns
characters in the source string. Unlike the overridden method
, this method may skip negative skip
distances: this rewinds the input so that characters may be read again.
When the end of the source string has been reached, the input cannot be
rewound.
ns | the maximum number of characters to skip. Positive values skip forward; negative values skip backward. |
---|
-(num chars already
read) <= distance skipped <= num chars remaining
.IOException | if this reader is closed. |
---|