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