java.io
Class StringReader
java.lang.Object
|
+--java.io.Reader
|
+--java.io.StringReader
public class
StringReaderextends
Reader This class permits a
String
to be read as a character
input stream.
The mark/reset functionality in this class behaves differently than
normal. If no mark has been set, then calling the reset()
method rewinds the read pointer to the beginning of the String
.
Authors:- Aaron M. Renn (arenn@urbanophile.com)
- Warren Levy <warrenl@cygnus.com>
StringReader
public StringReader(java.lang.String buffer)
Create a new StringReader
that will read chars from the
passed in String
. This stream will read from the beginning to the
end of the String
.
Parameters:
close
public void close()
mark
public void mark(int readAheadLimit)
Parameters:
markSupported
public boolean markSupported()
read
public int read()
read
public int read(char[] b, int off, int len)
Parameters:
ready
public boolean ready()
This method determines if the stream is ready to be read. This class
is always ready to read and so always returns true
, unless
close() has previously been called in which case an IOException is
thrown.
Returns:
true
to indicate that this object is ready to be read.
Throws:
reset
public void reset()
Sets the read position in the stream to the previously
marked position or to 0 (i.e., the beginning of the stream) if the mark
has not already been set.
skip
public long skip(long n)
This method attempts to skip the requested number of chars in the
input stream. It does this by advancing the pos
value by
the specified number of chars. It this would exceed the length of the
buffer, then only enough chars are skipped to position the stream at
the end of the buffer. The actual number of chars skipped is returned.
Parameters:
Returns:
- The actual number of chars skipped.
String
to be read as a character input stream.The mark/reset functionality in this class behaves differently than normal. If no mark has been set, then calling the
reset()
method rewinds the read pointer to the beginning of theString
.