Most visited

Recently visited

Added in API level 1

PipedWriter

public class PipedWriter
extends Writer

java.lang.Object
    java.io.Writer
      java.io.PipedWriter


管道字符输出流。

摘要(Summary)

Inherited fields

From class java.io.Writer

Public constructors

PipedWriter(PipedReader snk)

创建一个连接到指定管道读取器的管道写入器。

PipedWriter()

创建尚未连接到管道读取器的管道作者。

公共方法(Public methods)

void close()

关闭此管道输出流并释放与此流关联的所有系统资源。

void connect(PipedReader snk)

将此管道作者连接到接收器。

void flush()

刷新此输出流并强制写出所有缓冲的输出字符。

void write(int c)

将指定的 char写入管道输出流。

void write(char[] cbuf, int off, int len)

len字符从指定的字符数组开始,偏移量为 off写入此管道输出流。

继承方法(Inherited methods)

From class java.io.Writer
From class java.lang.Object
From interface java.lang.Appendable
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.AutoCloseable

Public constructors

PipedWriter

Added in API level 1
PipedWriter (PipedReader snk)

创建一个连接到指定管道读取器的管道写入器。 写入该流的数据字符将作为来自snk输入。

参数(Parameters)
snk PipedReader: The piped reader to connect to.
抛出异常(Throws)
IOException if an I/O error occurs.

PipedWriter

Added in API level 1
PipedWriter ()

创建尚未连接到管道读取器的管道作者。 在使用之前,必须通过接收器或发送器连接到管道读取器。

也可以看看:

公共方法(Public methods)

close

Added in API level 1
void close ()

关闭此管道输出流并释放与此流关联的所有系统资源。 此流可能不再用于写入字符。

抛出异常(Throws)
IOException if an I/O error occurs.

connect

Added in API level 1
void connect (PipedReader snk)

将此管道作者连接到接收器。 如果此对象已连接到某个其他管道读取器, IOException抛出IOException

如果 snk是未连接的管道读取器,而 src是未连接的管道作业器,则可以通过以下任一方式连接它们:

 src.connect(snk)
or the call:
 snk.connect(src)
The two calls have the same effect.

参数(Parameters)
snk PipedReader: the piped reader to connect to.
抛出异常(Throws)
IOException if an I/O error occurs.

flush

Added in API level 1
void flush ()

刷新此输出流并强制写出所有缓冲的输出字符。 这将通知任何读者角色在管道中等待。

抛出异常(Throws)
IOException if the pipe is closed, or an I/O error occurs.

write

Added in API level 1
void write (int c)

将指定的char写入管道输出流。 如果线程正在从连接的管道输入流中读取数据字符,但该线程不再有效,则会抛出IOException

实现 write的方法 Writer

参数(Parameters)
c int: the char to be written.
抛出异常(Throws)
IOException if the pipe is broken, unconnected, closed or an I/O error occurs.

write

Added in API level 1
void write (char[] cbuf, 
                int off, 
                int len)

len字符从指定的字符数组开始,偏移量为off写入此管道输出流。 此方法将阻止所有字符写入输出流。 如果线程正在从连接的管道输入流中读取数据字符,但该线程不再有效,则会抛出IOException

参数(Parameters)
cbuf char: the data.
off int: the start offset in the data.
len int: the number of characters to write.
抛出异常(Throws)
IOException if the pipe is broken, unconnected, closed or an I/O error occurs.

Hooray!