java的OutputStream的類型

來源:互聯網
上載者:User

這一類別包括的類決定了我們的輸入往何處去:

一個位元組數組(但沒有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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.