W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
java.lang.Object
|---java.io.Writer
|---|---java.io.PipedWriter
public class PipedWriter
extends Writer
管道字符輸出流。
Since:
JDK1.1
從類 java.io.Writer 繼承的字段 |
---|
lock |
構(gòu)造函數(shù) | 描述 |
---|---|
PipedWriter() | 創(chuàng)建一個尚未連接到管道讀取器的管道寫入器。 |
PipedWriter(PipedReader snk) | 創(chuàng)建連接到指定管道讀取器的管道寫入器。 |
修飾符和類型 | 方法 | 描述 |
---|---|---|
void | close() | 關(guān)閉此管道輸出流并釋放與此流關(guān)聯(lián)的任何系統(tǒng)資源。 |
void | connect(PipedReader snk) | 將此管道寫入器連接到接收器。 |
void | flush() | 刷新此輸出流并強制寫出任何緩沖的輸出字符。 |
void | write(char[] cbuf, int off, int len) | 將指定字符數(shù)組中的 len 個字符從 offset off 處開始寫入此管道輸出流。 |
void | write(int c) | 將指定的字符寫入管道輸出流。 |
從類 java.lang.Object 繼承的方法 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
從類 java.io.Writer 繼承的方法 |
---|
append, append, append, write, write, write |
public PipedWriter(PipedReader snk) throws IOException
創(chuàng)建連接到指定管道讀取器的管道寫入器。 然后,寫入此流的數(shù)據(jù)字符將可用作 snk 的輸入。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
snk | 要連接的管道閱讀器。 |
Throws:
Throw名稱 | Throw描述 |
---|---|
IOException | 如果發(fā)生 I/O 錯誤。 |
public PipedWriter()
創(chuàng)建一個尚未連接到管道讀取器的管道寫入器。 在使用之前,它必須通過接收器或發(fā)送器連接到管道閱讀器。
public void connect(PipedReader snk) throws IOException
將此管道寫入器連接到接收器。 如果此對象已連接到其他管道讀取器,則會引發(fā) IOException。
如果 snk 是一個未連接的管道讀取器并且 src 是一個未連接的管道寫入器,它們可以通過以下任一調(diào)用連接:
src.connect(snk)
或調(diào)用:
snk.connect(src)
這兩個調(diào)用具有相同的效果。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
snk | 要連接的管道閱讀器。 |
Throws:
Throw名稱 | Throw描述 |
---|---|
IOException | 如果發(fā)生 I/O 錯誤。 |
public void write(int c) throws IOException
將指定的字符寫入管道輸出流。 如果線程正在從連接的管道輸入流中讀取數(shù)據(jù)字符,但線程不再活動,則拋出 IOException。
實現(xiàn) Writer 的 write 方法。
覆蓋:
在 Writer 類中寫
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
c | 要寫入的字符。 |
Throws:
Throw名稱 | Throw描述 |
---|---|
IOException | 如果管道損壞、未連接、關(guān)閉或發(fā)生 I/O 錯誤。 |
public void write(char[] cbuf, int off, int len) throws IOException
將指定字符數(shù)組中的 len 個字符從 offset off 處開始寫入此管道輸出流。 此方法阻塞,直到所有字符都寫入輸出流。 如果線程正在從連接的管道輸入流中讀取數(shù)據(jù)字符,但線程不再活動,則拋出 IOException。
指定者:
在 Writer 類中寫
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
cbuf | 數(shù)據(jù)。 |
off | 數(shù)據(jù)中的起始偏移量。 |
len | 要寫入的字符數(shù)。 |
Throws:
Throw名稱 | Throw描述 |
---|---|
IOException | 如果管道損壞、未連接、關(guān)閉或發(fā)生 I/O 錯誤。 |
public void flush() throws IOException
刷新此輸出流并強制寫出任何緩沖的輸出字符。 這將通知任何讀者字符正在管道中等待。
指定者:
在接口 Flushable 中刷新
指定者:
在 Writer 類中刷新
Throws:
Throw名稱 | Throw描述 |
---|---|
IOException | 如果管道關(guān)閉,或者發(fā)生 I/O 錯誤。 |
public void close() throws IOException
關(guān)閉此管道輸出流并釋放與此流關(guān)聯(lián)的任何系統(tǒng)資源。 此流可能不再用于寫入字符。
指定者:
在接口 AutoCloseable 中關(guān)閉
指定者:
在接口Closeable中關(guān)閉
指定者:
close in class Writer
Throws:
Throw名稱 | Throw描述 |
---|---|
IOException | 如果發(fā)生 I/O 錯誤。 |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: