Stream definition

前端 未结 6 827
长发绾君心
长发绾君心 2021-02-05 11:01

I\'m reading on Java I/O streams and I\'m confused on the correct definition associated with them.

  • Some say that a stream is a sort of conveyor belt in which data
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 11:40

    Java programs perform I/O through streams. A stream is an abstraction that either produces or consumes information. A stream is linked to a physical device by the Java I/O system. All streams behave in the same manner, even if the actual physical devices to which they are linked differ. Thus, the same I/O classes and methods can be applied to any type of device. This means that an input stream can abstract many different kinds of input: from a disk file, a keyboard, or a network socket. Likewise, an output stream may refer to the console, a disk file, or a network connection. Streams are a clean way to deal with input/output without having every part of your code understand the difference between a keyboard and a network, for example. Java implements streams within class hierarchies defined in the java.io package.

    From: Java The Complete Reference

提交回复
热议问题