Name

BufferedReader

Synopsis

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.

java.io.BufferedReader

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 ...

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.