流定义

发布于 2024-11-15 09:42:57 字数 158 浏览 1 评论 0原文

我正在阅读 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

眼眸 2024-11-22 09:42:57

流是一个概念,但没有那么严格,只有一个描述是正确的。

I/O 流代表输入源或输出目的地。流可以表示许多不同类型的源和目的地,包括磁盘文件、设备、其他程序和内存阵列。
支持许多不同类型的数据,包括简单字节、原始数据类型、本地化字符和对象。有些流只是传递数据;有些流只是传递数据。其他人以有用的方式操纵和转换数据。

无论它们内部如何工作,所有流都向使用它们的程序呈现相同的简单模型:流是数据序列。

来自: 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.

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.)

温柔嚣张 2024-11-22 09:42:57

我想说 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.

跨年 2024-11-22 09:42:57

Java 程序通过流执行 I/O。流是一种抽象
产生或消耗信息。一个流链接到一个
Java I/O 系统的物理设备。所有流的行为都相同
方式,即使它们链接到的实际物理设备
不同。因此,相同的 I/O 类和方法可以应用于任何
设备类型。这意味着一个输入流可以抽象出许多
不同类型的输入:来自磁盘文件、键盘或网络
插座。同样,输出流可以指控制台、磁盘
文件或网络连接。流是一种干净的处理方式
输入/输出,而不让代码的每个部分都理解
例如,键盘和网络之间的区别。爪哇
在 java.io 中定义的类层次结构中实现流
包。

来自:Java 完整参考

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

妄断弥空 2024-11-22 09:42:57

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

蔚蓝源自深海 2024-11-22 09:42:57

可以这样想:流是您可以请求数据片段或向其发送数据片段的对象。

Just think it this way: Streams are objects that you can ask for pieces of data or send pieces of data to.

尝蛊 2024-11-22 09:42:57

在我看来,流实际上是一条传送带,正如您在第一点中提到的那样。实际上有两种类型的流:输入和输出。输入流用于从输入设备读取数据(如关键字)并将该数据写入文件,输出流用于从磁盘、文件等读取数据并将该数据写入输出设备(如控制台、监视器、 。

简单来说,它是一座帮助将物品从一处运输到另一处的桥梁

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文