Class: java.io.StringReader
- public class StringReader
- extends Reader
A character stream whose source is a string.
Methods
-
StringReadertop
public StringReader(String s)Creates a new string reader. -
closetop
public void close()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. -
marktop
public void mark(int readAheadLimit) throws IOExceptionMarks the present position in the stream. Subsequent calls to reset() will reposition the stream to this point. -
markSupportedtop
public boolean markSupported()Tells whether this stream supports the mark() operation, which it does.- Override hierarchy:
- markSupported from Reader
-
readtop
public int read() throws IOExceptionReads a single character. -
readtop
public int read(char[] cbuf, int off, int len) throws IOExceptionReads characters into a portion of an array. -
readytop
public boolean ready() throws IOExceptionTells whether this stream is ready to be read. -
resettop
public void reset() throws IOExceptionResets the stream to the most recent mark, or to the beginning of the string if it has never been marked. -
skiptop
public long skip(long ns) throws IOExceptionSkips the specified number of characters in the stream. Returns the number of characters that were skipped.The
nsparameter may be negative, even though theskipmethod of the java.io.Reader superclass throws an exception in this case. Negative values ofnscause 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.
