10.1 输入和输出
10.1 输入和输出
可将
很有必要按照功能对类进行分类。库的设计者首先决定与输入有关的所有类都从
(4) “管道”,它的工作原理与现实生活中的管道类似:将一些东西置入一端,它们在另一端出来。
除此以外,
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.
类 功能 构造器参数/如何使用
StringBuffer(字串缓冲)/作为一个数据源使用。通过将其同一个
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.
这一类别包括的类决定了我们的输入往何处去:一个字节数组(但没有
除此以外,
表
Class
Function
Constructor Arguments
How to use it
ByteArray-OutputStream
Creates a buffer in memory. All the data that you send to the stream is placed in this buffer.
Optional initial size of the buffer.
To designate the destination of your data. Connect it to a FilterOutputStream object to provide a useful interface.
File-OutputStream
For sending information to a file.
A String representing the file name, or a File or FileDescriptor object.
To designate the destination of your data. Connect it to a FilterOutputStream object to provide a useful interface.
Piped-OutputStream
Any information you write to this automatically ends up as input for the associated PipedInput-Stream. Implements the “piping” concept.
PipedInputStream
To designate the destination of your data for multithreading. Connect it to a FilterOutputStream object to provide a useful interface.
Filter-OutputStream
Abstract class which is an interface for decorators that provide useful functionality to the other OutputStream classes. See Table
10-4.
See Table 10-4.
See Table 10-4.
类 功能 构造器参数/如何使用