Name
BufferedWriter
Synopsis
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 with a FileWriter or
OutputStreamWriter.
BufferedWriter defines the standard
write( ), flush( ), and
close( ) methods all output streams define, but it
adds a newLine( ) method that 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.
Figure 9-4. java.io.BufferedWriter
public class BufferedWriter extends Writer { // Public Constructors public BufferedWriter(Writer out); public BufferedWriter(Writer out, int sz); // Public Instance Methods public void newLine( ) throws IOException; // Public Methods Overriding Writer public void close( ) throws IOException; public void flush( ) throws IOException; public void write(int c) throws IOException; public void write(char[ ] cbuf, int off, int len) throws IOException; public void write(String s, int off, int len) throws IOException; }
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access