Java Reference
In-Depth Information
The
append(charc)
method is equivalent to
write(c)
; the
append
methods
that take a
CharSequence
are equivalent to passing the
String
represent-
ations of the
CharSequence
objects to the
write(Stringstr)
method.
20.3.3. Character Streams and the Standard Streams
The standard streams
System.in
,
System.out
, and
System.err
existed be-
fore the character streams were invented, so these streams are byte
streams even though logically they should be character streams. This
situation creates some anomalies. It is impossible, for example, to re-
place
System.in
with a
LineNumberReader
to keep track of the standard in-
put stream's current line number. By attaching an
InputStreamReader
an
object that converts a byte input stream to a character input streamto
System.in
, you can create a
LineNumberReader
object to keep track of the
current line number (see "
LineNumberReader
" on page
527
). But
Sys-
tem.in
is an
InputStream
, so you cannot replace it with a
LineNumberReader
,
which is a type of
Reader
, not an
InputStream
.
System.out
and
System.err
are
PrintStream
objects.
PrintStream
has been
replaced by its equivalent character-based version
PrintWriter
. Gener-
ally, you should avoid creating
PrintStream
objects directly. You'll learn