A BufferedWriter is a Writer that adds a flush( ) method that can be used to ensure that data buffers are physically written to the actual output stream. Using a BuffcredWritcr can increase performance by reducing the number of times data is actually physically written to the output stream.

The first form creates a buffered stream using a buffer with a default size. In the second, the size of the buffer is passed in blif Sizc.


The PushbackReader class 'allows one or more characters to be returned to the input stream. This allows you to look ahead in the input stream. Here are its two constructors.

The first form creates a buffered stream that allows one character to be pushed back. In the second, the size of the pushback buffer is passed in bufSize.

Pushbackreader provides unread( ), which returns one or more characters to the invoking input stream. It has the three forms shown here.

The following program reworks the earlier PushBackinputStream example by replacing Pushllacklnput'Stream with a PushbackReader. As before, it shows how a programming language parser can use a pushback stream to deal with the difference between the == operator for comparison and the  operator for assignment.

Share This