Input and Output
4. Standard Streams
Answer:
A stream of characters is input (from a file) and later a stream of characters is output (often to the same file).
Standard Streams
Some programs read in the entire input stream before they write the output stream. Other programs read the input stream item by item and write one output item for each input item. There are many other patterns of input and output. In general, a program may have several input streams flowing into it and several output streams flowing out of it.
There are three standard I/O streams:
- System.in — the input stream.
- System.out — the output stream for normal results.
- System.err — the output stream for error messages.
Normally System.in
is connected to the keyboard and the data are characters. System.out
and System.err
both are connected to the monitor, and also contain character data. These
notes use System.err
only occasionally.
Question 4:
What does the keyboard send to your program when you type the following:
1234