public class StringReader extends Reader
Readerthat reads characters from a
Stringin a sequential manner.
|Constructor and Description|
Construct a new
|Modifier and Type||Method and Description|
Closes this reader.
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
public StringReader(java.lang.String str)
stras source. The size of the reader is set to the
length()of the string.
str- the source string for this reader.
public void close()
IOException. Only the first invocation of this method has any effect.
public int read()
public int read(char buf, int offset, int length)
lencharacters from the source string and stores them at
offsetin 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
bufferto store the characters read from this reader
length- the maximum number of characters to read
offset < 0or
len < 0, or if
offset + lenis greater than the size of
IOException- if this reader is closed