A
PrintStream
adds functionality to another output stream, namely the ability to print representations of various data values conveniently. Two other features are provided as well. Unlike other output streams, a
PrintStream
never throws an
IOException
; instead, exceptional situations merely set an internal flag that can be tested via the
checkError
method. Optionally, a
PrintStream
can be created so as to flush automatically; this means that the
flush
method is automatically invoked after a byte array is written, one of the
println
methods is invoked, or a newline character or byte (
'\n'
) is written.
All characters printed by a PrintStream
are converted into bytes using the platform's default character encoding. The {@link PrintWriter}
class should be used in situations that require writing characters rather than bytes.
@author Frank Yellin
@author Mark Reinhold
@since JDK1.0