Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.io

Class StringReader

java.lang.Object
|
+--java.io.Reader
   |
   +--java.io.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.

Authors:

Constructor Summary

StringReader(java.lang.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 Details

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:


Method Details

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:

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: