Java Input / Output (I/O Streams)

  • Data represents information.
  • Input refers to the data provided to the computer program for processing and the program generates the output after processing and displays onto the monitor.
  • Generally the input is given to the program through input source such as keyboard, mouse or as a file.
  • The output is displayed onto the monitor as an action.
  • The flow of data from one place to another is called stream.
  • The flow of data from the input source to the program for processing is called input stream.
  • Input stream is used to read the data from the source.
  • The flow of data from the program to the monitor or the destination is called output stream.
  • Output stream is used to write data.
  • Java.io package contains classes which handle the input and output streams.

The System Class:

The system class is a final class under Java.lang package and cannot be instantiated. It has three fields which are static, they are in, out and err.

  • System.in represents Inputstream object. This input stream refers to the input source specified by the user (eg) Keyboard.
  • System.out represents Outputstream object. This output stream is used to display the output onto the destination specified by the user such as monitor,  etc.
  • System.err represents Outputstream object. This output stream is used to display error messages onto the monitor.

 

Share this website !!!
Facebook Twitter Linkedin