Differences between System.out x System.err x System.in?

6

I did not find any discussion on this question here in the community so I decided to create this topic. There is a well-told question among beginners in the Java language when it comes to data manipulation.

  • What is the difference between the three commands?
  • Which should be used in each case?
  • And what is the most effective?
asked by anonymous 24.04.2017 / 19:02

2 answers

3

System.out is the default output of the system you are using. System.err is the default output of system errors. In a normal console application, both are likely to run on the console. But you can reconfigure the outputs to, for example, make the errors print in a text file, and leave the System.out printable on the screen.

System.in is the system input pattern, of type InputStream . It is already open, and ready to receive data. Typically, it matches the keyboard or any specified data source either by the environment, or by the users.

System.in - > You receive data

System.out and System.err - > They do data output. Can be reconfigured to write in different places

    
24.04.2017 / 19:14
1

System.in

Default entry of type InputStream , usually connected to the keyboard in terminal / console-oriented programs.

System.out

Standard output of type PrintStream . Usually sends the data recorded on it to the console / terminal. Much used by console-based programs such as command line tools ( grep , find ).

System.err

Error output of type PrintStream . It works like System.out, except it is used to send error messages.

In a terminal-oriented Java application, both outputs will be the same (the command line), but you can reconfigure them so that Sistem.out continues to print to the terminal, and System.err writes to a file, for example.

This reconfiguration can be done directly on the terminal as these examples.

    
24.04.2017 / 19:16