Name

StringReader

Synopsis

This class is a character input stream that uses a String object as the source of the characters it returns. When you create a StringReader, you must specify the String to read from. StringReader defines the normal Reader methods and supports mark( ) and reset( ). If reset( ) is called before mark( ) has been called, the stream is reset to the beginning of the specified string. StringReader is a character stream analog to StringBufferInputStream, which is deprecated as of Java 1.1. StringReader is also similar to CharArrayReader.

java.io.StringReader

Figure 9-59. java.io.StringReader

public class StringReader extends Reader {
// Public Constructors
     public StringReader(String s);  
// Public Methods Overriding Reader
     public void close( );  
     public void mark(int readAheadLimit) throws IOException;  
     public boolean markSupported( );                                     constant
     public int read( ) throws IOException;  
     public int read(char[ ] cbuf, int off, int len) throws IOException;  
     public boolean ready( ) throws IOException;  
     public void reset( ) throws IOException;  
     public long skip(long ns) throws IOException;  
}

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.