Java I/O   

The package contains all the classes required for input and output operations. Java uses the concept of stream to make I/O operation fast.

Stream:  It's called a stream because it's like a stream of water that continues to flow. A stream is a sequence of data. In Java a stream is composed of bytes. In java, 3 streams are created for us automatically. All these streams are attached with console.

                           1) System.out: standard output stream

                            2) standard input stream

                            3) System.err: standard error stream  

//code to print output and error message to the console.

                       1.    System.out.println("simple message");  

                       2.    System.err.println("error message");  

  // code to get input from console.

                   int;//returns ASCII code of 1st character  

                   System.out.println ((char) i);//will print the character   



An Output Stream to write data to a destination, it may be a file,an array, peripheral device or socket.


            OutputStream class is an abstract class. It is the superclass of all classes representing an output stream of bytes.




an input stream to read data from a source, it may be a file,an array,peripheral device or socket.

      InputStream class is an abstract class.It is the superclass of all classes representing an input stream of bytes.


Leave Comment