Search code examples
javainputstreamoutputstream

How is an Input Stream different from an Output Stream?


I see that both are "streams" of data. In that case, why consider them different ? What is the difference really ?

Comment - Please don't close this question. It is the basic kind of stuff that can confound people in an interview.

UPDATE 1 - Everyone seems to say the same thing - you read from IS and write into OS. So, they are basically the same. Like a pipe with water flowing through it. When you use the water from that pipe you call it InputStream and When you pump water into it, its called an output stream. Is it really that trivial ?

UPDATE2 - If the difference is not so "big", then can we have a InAndOutStream instead of having to make code for two classes (InputStream and OutputStream) ?


Solution

  • They are conceptually different

    • from InputStream you read
    • to OutputStream you write