java的InputStream的类型2007-05-28 yycnet.yeah.net yyc译InputStream的作用是标志那些从不同起源地产生输入的类。这些起源地包括(每个都有一个相关的InputStream子类):
(1) 字节数组
(2) String对象
(3) 文件
(4) “管道”,它的工作原理与现实生活中的管道类似:将一些东西置入一端,它们在另一端出来。 (5) 一系列其他流,以便我们将其统一收集到单独一个流内。
(6) 其他起源地,如Internet连接等(将在本书后面的部分讲述)。
除此以外,FilterInputStream也属于InputStream的一种类型,用它可为“破坏器”类提供一个基础类,以便将属性或者有用的接口同输入流连接到一起。这将在以后讨论。
Class
| Function
| Constructor Arguments
|
---|
How to use it
|
---|
ByteArray-InputStream
| Allows a buffer in memory to be used as an InputStream.
| The buffer from which to extract the bytes.
|
As a source of data. Connect it to a FilterInputStream object to provide a useful interface.
|
StringBuffer-InputStream
| Converts a String into an InputStream.
| A String. The underlying implementation actually uses a StringBuffer.
|
As a source of data. Connect it to a FilterInputStream object to provide a useful interface.
|
File-InputStream
| For reading information from a file.
| A String representing the file name, or a File or FileDescriptor object.
|
As a source of data. Connect it to a FilterInputStream object to provide a useful interface.
|
类 功能 构建器参数/如何使用
ByteArrayInputStream 允许内存中的一个缓冲区作为InputStream使用 从中提取字节的缓冲区/作为一个数据源使用。通过将其同一个FilterInputStream对象连接,可提供一个有用的接口
StringBufferInputStream 将一个String转换成InputStream 一个String(字串)。基础的实施方案实际采用一个StringBuffer(字串缓冲)/作为一个数据源使用。通过将其同一个FilterInputStream对象连接,可提供一个有用的接口
FileInputStream 用于从文件读取信息 代表文件名的一个String,或者一个File或FileDescriptor对象/作为一个数据源使用。通过将其同一个FilterInputStream对象连接,可提供一个有用的接口
Piped-InputStream
| Produces the data that’s being written to the associated PipedOutput-Stream. Implements the “piping” concept.
| PipedOutputStream
|
As a source of data in multithreading. Connect it to a FilterInputStream object to provide a useful interface.
|
Sequence-InputStream
| Coverts two or more InputStream objects into a single InputStream.
| Two InputStream objects or an Enumeration for a container of InputStream objects.
|
As a source of data. Connect it to a FilterInputStream object to provide a useful interface.
|
Filter-InputStream
| Abstract class which is an interface for decorators that provide useful functionality to the other InputStream classes. See Table 10-3.
| See Table 10-3.
|
See Table 10-3.
|
PipedInputString 产生为相关的PipedOutputStream写的数据。实现了“管道化”的概念 PipedOutputStream/作为一个数据源使用。通过将其同一个FilterInputStream对象连接,可提供一个有用的接口
SequenceInputStream 将两个或更多的InputStream对象转换成单个InputStream使用 两个InputStream对象或者一个Enumeration,用于InputStream对象的一个容器/作为一个数据源使用。通过将其同一个FilterInputStream对象连接,可提供一个有用的接口
FilterInputStream 对作为破坏器接口使用的类进行抽象;那个破坏器为其他InputStream类提供了有用的功能。参见表10.3