What is the difference between the "standard streams" (System.out
, System.in
, System.err
) and the "Console" (System.console()
) in Java?

- 54,589
- 14
- 104
- 138

- 1,403
- 3
- 12
- 21
-
Please be more specific. Do you mean the workings of `System.out` and `System.err`? – hellectronic Oct 26 '11 at 19:04
-
2Please elaborate on your question. – Dan W Oct 26 '11 at 19:06
-
@normalocity can you please answer this question? – Rekha Oct 27 '11 at 05:20
-
can anyone answer this question? – Rekha Oct 27 '11 at 05:20
-
@Dan @ hellectronic w can you please answer the question if the question is clear – Rekha Oct 27 '11 at 05:40
-
Possible duplicate of [BufferedReader vs Console vs Scanner](https://stackoverflow.com/questions/17637032/bufferedreader-vs-console-vs-scanner) – Bernhard Barker Oct 26 '17 at 12:07
-
1if people ask you to be more specific it doesn't help to ask them in the comments to answer your question without actually being more specific.. – Neuron Oct 26 '17 at 12:19
2 Answers
Every process (not just Java programs) have three streams: in, out, and error. In Java access to these has been simplified to System.in, System.out, and System.err. These are used for reading from or writing to the command line. For example, if you ever had a command line program that asked for input, which you typed and then pressed enter, that input went to standard in.
There are two out streams (out and err), because they report different things. For example, you might want to save the error output but not care about the generic output a program prints out. Or you might want to suppress the standard output so only errors are printed. Or you have a program with all kinds of problems and you want to suppress the errors so you can see what it's trying to do and not 10 million stack traces.
So, the short answer to your question is that the standard streams are ways of writing to and reading from the console.

- 4,047
- 2
- 24
- 33
-
This doesn't really answer the question. There's `System.console()`, which returns a `Console` object. – Bernhard Barker Oct 26 '17 at 12:08
In short, a console is the thing that might capture the streams and display them on a screen. Every program has access to the input/output streams, but not every program has access to a console.
Some programs lose access to the console as their streams are initially (or eventually redirected). Other programs are launched in configurations where they never had access to a console. In the latter case, everything written to System.out
might as well have been written to /dev/null
.
While this applies to Java, the Console (and the "other side" of the streams) are really operating system concepts.

- 69,361
- 7
- 100
- 138