Team LiB
Previous Section Next Section

BufferedReaderjava.io

Java 1.1readable closeable

This class applies buffering to a character input stream, thereby improving the efficiency of character input. You create a BufferedReader by specifying some other character input stream from which it is to buffer input. (You can also specify a buffer size at this time, although the default size is usually fine.) Typically, you use this sort of buffering with a FileReader or InputStreamReader. BufferedReader defines the standard set of Reader methods and provides a readLine( ) method that reads a line of text (not including the line terminator) and returns it as a String. BufferedReader is the character-stream analog of BufferedInputStream. It also provides a replacement for the deprecated readLine( ) method of DataInputStream, which did not properly convert bytes into characters.

Figure 9-3. java.io.BufferedReader


public class BufferedReader extends Reader {
// Public Constructors
     public BufferedReader(Reader in);  
     public BufferedReader(Reader in, int sz);  
// Public Instance Methods
     public String readLine( ) throws IOException;  
// Public Methods Overriding Reader
     public void close( ) throws IOException;  
     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 n) throws IOException;  
}

Subclasses

LineNumberReader

    Team LiB
    Previous Section Next Section