Stream definition

前端 未结 6 947
长发绾君心
长发绾君心 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:49

    A stream is a concept, but it's not that strict, that just only one description would be correct.

    An I/O Stream represents an input source or an output destination. A stream can represent many different kinds of sources and destinations, including disk files, devices, other programs, and memory arrays. Streams support many different kinds of data, including simple bytes, primitive data types, localized characters, and objects. Some streams simply pass on data; others manipulate and transform the data in useful ways.

    No matter how they work internally, all streams present the same simple model to programs that use them: A stream is a sequence of data.

    From: http://download.oracle.com/javase/tutorial/essential/io/streams.html

    Also a stream is either an input stream or output stream. If it is an input stream, in Java it will adhere to the InputStream interface, the latter to the Outputstream.

    (Side note: In crypto, there's e.g. a difference between stream and block ciphers, where a stream cipher is something that does not know (in a very general sense) anything about the future, while a block cipher knows its (maximum) size in advance and the sizes of all coming blocks.)

提交回复
热议问题