Friday 13 January 2012

INPUT AND OUTPUT IN JAVA

We all know what is mean by input and output. In terms of programming input is nothing but giving some  data to the program for processing and getting some data is known as output in terms of programming.


Input and output JAVA 
  When you want to get a input from your keyboard or from file or any other source and send a output to console or file or any other destination JAVA associates a stream with it.

Now our first questions is what the heck this "STREAM" means ?

   As per the oracle documentation, Stream is flow of data(here data means 0's and 1's)from source to destination.if you still cannot able to understand what is mean by stream ? means then consider stream as a pipe through which water flows from one end to another end.
                      STREAM DIAGRAM

 As shown in the above diagram data[every thing in computer is stored as zero's and one's] will flow from one end to another.

So when you want a input from keyboard JAVA associates(connects) your program with the keyboard using a stream as show in the diagram below :

     
          
    So this is called as stream in JAVA. Easy right.