java.io

Class StringReader

public class StringReader extends 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.

UNKNOWN: October 19, 1998.

Constructor Summary
StringReader(String buffer)
Create a new StringReader that will read chars from the passed in String.
Method Summary
voidclose()
voidmark(int readAheadLimit)
booleanmarkSupported()
intread()
intread(char[] b, int off, int len)
booleanready()
This method determines if the stream is ready to be read.
voidreset()
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.
longskip(long n)
This method attempts to skip the requested number of chars in the input stream.

Constructor Detail

StringReader

public StringReader(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: buffer The String this stream will read from.

Method Detail

close

public void close()

mark

public void mark(int readAheadLimit)

markSupported

public boolean markSupported()

read

public int read()

read

public int read(char[] b, int off, int len)

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: IOException If the stream is closed.

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: n The requested number of chars to skip

Returns: The actual number of chars skipped.