Java Stream

Stream

  • Stream carries data just as a water pipe carries water from one place to another
  • A stream is a sequence of data
  • Streams can be categorized as ‘input stream’ and ‘output stream’
  • Input streams are the streams which receive or read data
  • Output streams are the streams which send or write data
  • All streams are represented by classes in java.io package

A stream has following three streams:

System.in: represent InputStream object. This object represent the standard input device, that is keyboard by default.

System.out: represent PrintStream object. This object by default represents the standard output device, that is monitor.

System.err: represents PrintStream object. This object by default represents the standard output device, that is monitor.


What is difference between System.out and System.err?

System.out is used to display normal messages as,

System.out.println(“Hello”);

System.err is used to display any error messages in the program as,

System.err.println(“This an error”);


 

Leave a Reply

Your email address will not be published. Required fields are marked *