Print formatted representations of objects to a text-output stream. This
class implements all of the print methods found in PrintStream. It does not
contain methods for writing raw bytes, for which a program should use
unencoded byte streams.
Unlike the PrintStream class, if automatic flushing is enabled it will
be done only when one of the println() methods is invoked, rather than
whenever a newline character happens to be output. The println() methods
use the platform's own notion of line separator rather than the newline
character.
Methods in this class never throw I/O exceptions. The client may
inquire as to whether any errors have occurred by invoking checkError().
Create a new PrintWriter, without automatic line flushing, from an
existing OutputStream. This convenience constructor creates the
necessary intermediate OutputStreamWriter, which will convert characters
into bytes using the default character encoding.
PrintWriter
public PrintWriter(OutputStream out,
boolean autoFlush)
Create a new PrintWriter from an existing OutputStream. This
convenience constructor creates the necessary intermediate
OutputStreamWriter, which will convert characters into bytes using the
default character encoding.
Parameters:
out - An output stream
autoFlush - A boolean; if true, the println() methods will flush
the output buffer
Flush the stream and check its error state. Errors are cumulative;
once the stream encounters an error, this routine will return true on
all successive calls.
Returns:
True if the print stream has encountered an error, either on the
underlying output stream or during a format conversion.