What is InputStream & Output Stream? Why and when do we use them?

前端 未结 8 988
予麋鹿
予麋鹿 2020-11-29 14:09

Someone explain to me what InputStream and OutputStream are?

I am confused about the use cases for both InputStream and

8条回答
  •  -上瘾入骨i
    2020-11-29 15:12

    A stream is a continuous flow of liquid, air, or gas.

    Java stream is a flow of data from a source into a destination. The source or destination can be a disk, memory, socket, or other programs. The data can be bytes, characters, or objects. The same applies for C# or C++ streams. A good metaphor for Java streams is water flowing from a tap into a bathtub and later into a drainage.

    The data represents the static part of the stream; the read and write methods the dynamic part of the stream.

    InputStream represents a flow of data from the source, the OutputStream represents a flow of data into the destination. Finally, InputStream and OutputStream are abstractions over low-level access to data, such as C file pointers.

提交回复
热议问题