Java in a Nutshell

Previous Chapter 24
The java.io Package
Next
 

24.4 java.io.BufferedWriter (JDK 1.1)

This class applies buffering to a character output stream, improving output efficiency by coalescing many small write requests into a single larger request. You create a BufferedWriter by specifying some other character output stream to which it sends its buffered and coalesced output. (You can also specify a buffer size at this time, although the default size is usually satisfactory.) Typically you use this sort of buffering when you are using a FileWriter or OutputStreamWriter.

BufferedWriter defines the standard write(), flush(), and close() methods that all output streams define, but it also adds a newLine() method, which outputs the platform-dependent line separator (usually a newline character, a carriage return character, or both) to the stream.

BufferedWriter is the character-stream analog of BufferedOutputStream.

public class BufferedWriter extends Writer {
    // Public Constructors
            public BufferedWriter(Writer out);
            public BufferedWriter(Writer out, int sz);
    // Public Instance Methods
            public void close() throws IOException;  // Defines Writer
            public void flush() throws IOException;  // Defines Writer
            public void newLine() throws IOException;
            public void write(int c) throws IOException;  // Overrides Writer
            public void write(char[] cbuf, int off, int len) throws IOException;  // Defines Writer
            public void write(String s, int off, int len) throws IOException;  // Overrides Writer
}

Hierarchy:

Object->Writer->BufferedWriter


Previous Home Next
java.io.BufferedReader (JDK 1.1) Book Index java.io.ByteArrayInputStream (JDK 1.0)

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java