当前位置:天才代写 > tutorial > JAVA 教程 > java的OutputStream的范例

java的OutputStream的范例

2017-11-13 08:00 星期一 所属: JAVA 教程 浏览:324

这一种别包罗的类抉择了我们的输入往那里去:

一个字节数组(但没有String;假定我们可用字节数组建设一个);
一个文件;可能一个“管道”。

除此以外,FilterOutputStream为“粉碎器”类提供了一个基本类,它将属性可能有用的接口同输出流毗连起来。这将在今后接头。

表10.2 OutputStream的范例
 

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.
 

类 成果 构建器参数/如何利用

ByteArrayOutputStream 在内存中建设一个缓冲区。我们发送给流的所有数据城市置入这个缓冲区。 可选缓冲区的初始巨细/用于指出数据的目标地。若将其同FilterOutputStream工具毗连到一起,可提供一个有用的接口
FileOutputStream 将信息发给一个文件 用一个String代表文件名,或选用一个File或FileDescriptor工具/用于指出数据的目标地。若将其同FilterOutputStream工具毗连到一起,可提供一个有用的接口
PipedOutputStream 我们写给它的任何信息城市自动成为相关的PipedInputStream的输出。实现了“管道化”的观念 PipedInputStream/为多线程处理惩罚指出本身数据的目标地/将其同FilterOutputStream工具毗连到一起,便可提供一个有用的接口
FilterOutputStream 对作为粉碎器接口利用的类举办抽象处理惩罚;谁人粉碎器为其他OutputStream类提供了有用的成果。拜见表10.4

 

    关键字:

天才代写-代写联系方式