流定义
我正在阅读 Java I/O 流,但我对与它们相关的正确定义感到困惑。
- 有人说流是一种传输数据的传送带...
- 其他人说流是流或 数据序列...
- 或者说流是 连接到输入或输出 来源...
那么正确的定义是什么?
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 are transmitted...
- other say that a stream is a flow or
a sequence of a data... - other say that a stream is a
connection to an input or an output
source...
So what's the correct definition?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
流是一个概念,但没有那么严格,只有一个描述是正确的。
来自: http://download.oracle.com/javase/tutorial/essential /io/streams.html
另外,流可以是输入流,也可以是输出流。如果它是输入流,在 Java 中它将遵循
InputStream
接口,后者为输出流
。(旁注:在加密中,流密码和分组密码之间存在差异,其中流密码是不知道(在非常普遍的意义上)关于未来的任何事情,而分组密码提前知道它的(最大)大小以及所有即将到来的块的大小。)
A stream is a concept, but it's not that strict, that just only one description would be correct.
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 theOutputstream
.(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.)
我想说 Stream 就像所有这些,但又不完全是其中任何一个。
我想说它是一个 8 位字节的有序序列。
I would say a Stream is like all of these, but not exactly any of these.
I would say its an ordered sequence of 8-bit bytes.
来自:Java 完整参考
From: Java The Complete Reference
Java 执行 I/O 抛出流。流是产生或消耗信息的抽象。流通过 java I/O 流链接到物理设备。流是一种处理输入或输出的干净方法,无需理解代码的每个部分。
Java定义了两种类型的流:字节流和字符流
Java performs I/O throw 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 stream. Streams are a cleaned way to deal with input or output without having every part of code understand.
Java defines two types of stream: byte and character
可以这样想:流是您可以请求数据片段或向其发送数据片段的对象。
Just think it this way: Streams are objects that you can ask for pieces of data or send pieces of data to.
在我看来,流实际上是一条传送带,正如您在第一点中提到的那样。实际上有两种类型的流:输入和输出。输入流用于从输入设备读取数据(如关键字)并将该数据写入文件,输出流用于从磁盘、文件等读取数据并将该数据写入输出设备(如控制台、监视器、 。
简单来说,它是一座帮助将物品从一处运输到另一处的桥梁
In my viewpoint stream is actually a conveyor belt as you mention in the first point. Actually there are two types of stream, input, and output. An input stream is used to read the data from the input device like keywords and write that data to the files and output stream is used to read data from the disks, files, etc and write that data to the output device like console, monitor, etc.
In a simple way, it is the bridge that helps to transport things from one point to another.