About

Standard Streams are a feature of many operating systems. By default, they:

  • read input from the keyboard
  • and write output to the display.

They are the building block of interaction with the user in a command line environment. The application catch them and manipulate them to interact with the user or other programs.

The three I/O connections are called:

  • standard input (stdin) - Read from the keyboard or from a redirection such as the pipe.
  • standard output (stdout) - Print to the display and can be redirected as standard input.
  • and standard error (stderr) - Same as stdout but normally only for errors. Having error output separately allows the user to divert regular output to a file and still be able to read error messages.

They are generally implemented as open files that point to the standard input, standard output, and standard error file descriptors.

They are properties of every process

Language

Language stdin stdout stderr
Java System.in System.out System.err
C Unix file descriptors 0 Unix file descriptors 1 Unix file descriptors 2

Method

Redirection

Standard streams also support I/O on files and between programs, but that feature is controlled by the command line interpreter, not the program.

See What are Shell Redirections? of Standard Streams