The Console: System.out, System.in, and System.err
The console
is the default destination for output written to
System.out
or
System.err
and the default source of input for
System.in
.
On most platforms the console is the command-line environment from
which the Java program was initially launched, perhaps an
xterm (Figure 1.1) or a DOS
shell window (Figure 1.2). The word
console is something of a misnomer, since on
Unix systems the console refers to a very specific command-line
shell, rather than being a generic term for command-line shells
overall.

Figure 1-1. An xterm console on Unix

Figure 1-2. A DOS shell console on Windows NT
Many common misconceptions about I/O occur because most programmers’ first exposure to I/O is through the console. The console is convenient for quick hacks and toy examples commonly found in textbooks, and I will use it for that in this book, but it’s really a very unusual source of input and destination for output, and good Java programs avoid it. It behaves almost, but not completely, unlike anything else you’d want to read from or write to. While consoles make convenient examples in programming texts like this one, they’re a horrible user interface and really have little place in modern programs. Users are more comfortable with a well-defined graphical ...
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