|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
java.io.StringReader
public class StringReader
A specialized Reader that reads characters from a String in
a sequential manner.
StringWriter| Field Summary |
|---|
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
StringReader(String str)
Construct a new StringReader with str as source. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this reader. |
void |
mark(int readLimit)
Sets a mark position in this reader. |
boolean |
markSupported()
Indicates whether this reader supports the mark() and reset() methods. |
int |
read()
Reads a single character from the source string and returns it as an integer with the two higher-order bytes set to 0. |
int |
read(char[] buf,
int offset,
int len)
Reads at most len characters from the source string and stores
them at offset in the character array buf. |
boolean |
ready()
Indicates whether this reader is ready to be read without blocking. |
void |
reset()
Resets this reader's position to the last mark() location. |
long |
skip(long ns)
Skips amount characters in the source string. |
| 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 str)
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.| Method Detail |
|---|
public void close()
IOException. Only the first invocation of this
method has any effect.
close in interface Closeableclose in class Reader
public void mark(int readLimit)
throws IOException
readLimit is
ignored for this class. Calling reset() will reposition the
reader back to the marked position.
mark in class ReaderreadLimit - ignored for StringReader instances.
IllegalArgumentException - if readLimit < 0.
IOException - if this reader is closed.markSupported(),
reset()public boolean markSupported()
mark() and reset() methods. This implementation returns true.
markSupported in class Readertrue.
public int read()
throws IOException
read in class ReaderIOException - if this reader is closed.
public int read(char[] buf,
int offset,
int len)
throws IOException
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.
read in class Readerbuf - 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.
public boolean ready()
throws IOException
true.
ready in class Readertrue.
IOException - if this reader is closed.read(),
read(char[], int, int)
public void reset()
throws IOException
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.
reset in class ReaderIOException - if this reader is closed.mark(int),
markSupported()
public long skip(long ns)
throws IOException
amount characters in the source string. Subsequent calls of
read methods will not return these characters unless reset() is used.
skip in class Readerns - the maximum number of characters to skip.
ns < 0.
IOException - if this reader is closed.mark(int),
markSupported(),
reset()
|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||