新聞中心
BufferedOutputStream

java.lang.Object
|---java.io.OutputStream
|---|---java.io.FilterOutputStream
|---|---|---java.io.BufferedOutputStream
public class BufferedOutputStream
extends FilterOutputStream該類實現(xiàn)了一個緩沖的輸出流。 通過設(shè)置這樣的輸出流,應(yīng)用程序可以將字節(jié)寫入底層輸出流,而不必為每個寫入的字節(jié)調(diào)用底層系統(tǒng)。
Since:
JDK1.0
字段摘要
| 修飾符和類型 | 字段 | 描述 |
|---|---|---|
| protected byte[] | buf | 存儲數(shù)據(jù)的內(nèi)部緩沖區(qū)。 |
| protected int | count | 緩沖區(qū)中的有效字節(jié)數(shù)。 |
| 從類 java.io.FilterOutputStream 繼承的字段 |
|---|
| out |
構(gòu)造函數(shù)摘要
| 構(gòu)造函數(shù) | 描述 |
|---|---|
| BufferedOutputStream(OutputStream out) | 創(chuàng)建一個新的緩沖輸出流以將數(shù)據(jù)寫入指定的基礎(chǔ)輸出流。 |
| BufferedOutputStream(OutputStream out, int size) | 創(chuàng)建一個新的緩沖輸出流,以將數(shù)據(jù)寫入具有指定緩沖區(qū)大小的指定基礎(chǔ)輸出流。 |
方法總結(jié)
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| void | flush() | 刷新此緩沖輸出流。 |
| void | write(byte[] b, int off, int len) | 從偏移量 off 開始的指定字節(jié)數(shù)組中寫入 len 個字節(jié)到此緩沖輸出流。 |
| void | write(int b) | 將指定字節(jié)寫入此緩沖輸出流。 |
| 從類 java.io.FilterOutputStream 繼承的方法 |
|---|
| close, write |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
字段詳細信息
buf
protected byte[] buf
存儲數(shù)據(jù)的內(nèi)部緩沖區(qū)。
count
protected int count
緩沖區(qū)中的有效字節(jié)數(shù)。 該值始終在 0 到 buf.length 的范圍內(nèi); 元素 buf[0] 到 buf[count-1] 包含有效的字節(jié)數(shù)據(jù)。
構(gòu)造函數(shù)詳細信息
BufferedOutputStream
public BufferedOutputStream(OutputStream out)
創(chuàng)建一個新的緩沖輸出流以將數(shù)據(jù)寫入指定的基礎(chǔ)輸出流。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| out | 底層輸出流。 |
BufferedOutputStream
public BufferedOutputStream(OutputStream out, int size)
創(chuàng)建一個新的緩沖輸出流,以將數(shù)據(jù)寫入具有指定緩沖區(qū)大小的指定基礎(chǔ)輸出流。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| out | 底層輸出流。 |
| size | 緩沖區(qū)大小。 |
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| IllegalArgumentException | 如果 size <= 0. |
方法詳情
write
public void write(int b) throws IOException
將指定字節(jié)寫入此緩沖輸出流。
覆蓋:
寫在類 FilterOutputStream
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| b | 要寫入的字節(jié)。 |
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| IOException | 如果發(fā)生 I/O 錯誤。 |
write
public void write(byte[] b, int off, int len) throws IOException
從偏移量 off 開始的指定字節(jié)數(shù)組中寫入 len 個字節(jié)到此緩沖輸出流。
通常,此方法將給定數(shù)組中的字節(jié)存儲到此流的緩沖區(qū)中,并根據(jù)需要將緩沖區(qū)刷新到底層輸出流。 但是,如果請求的長度至少與此流的緩沖區(qū)一樣大,則此方法將刷新緩沖區(qū)并將字節(jié)直接寫入底層輸出流。 因此冗余的 BufferedOutputStreams 不會不必要地復(fù)制數(shù)據(jù)。
覆蓋:
寫在類 FilterOutputStream
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| b | 數(shù)據(jù)。 |
| off | 數(shù)據(jù)中的起始偏移量。 |
| len | 要寫入的字節(jié)數(shù)。 |
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| IOException | 如果發(fā)生 I/O 錯誤。 |
flush
public void flush() throws IOException
刷新此緩沖輸出流。 這會強制將任何緩沖的輸出字節(jié)寫出到底層輸出流。
指定者:
在接口 Flushable 中刷新
覆蓋:
類 FilterOutputStream 中的刷新
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| IOException | 如果發(fā)生 I/O 錯誤。 |
新聞標(biāo)題:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSBufferedOutputStream
本文路徑:http://m.5511xx.com/article/cdidsoc.html


咨詢
建站咨詢
