public class PipedWriter
extends Writer
| java.lang.Object | ||
| ↳ | java.io.Writer | |
| ↳ | java.io.PipedWriter | |
管道字符输出流。
Inherited fields |
|---|
java.io.Writer
|
Public constructors |
|
|---|---|
PipedWriter(PipedReader snk) 创建一个连接到指定管道读取器的管道写入器。 |
|
PipedWriter() 创建尚未连接到管道读取器的管道作者。 |
|
Public methods |
|
|---|---|
void |
close() 关闭此管道输出流并释放与此流关联的所有系统资源。 |
void |
connect(PipedReader snk) 将此管道作者连接到接收器。 |
void |
flush() 刷新此输出流并强制写出所有缓冲的输出字符。 |
void |
write(int c) 将指定的 |
void |
write(char[] cbuf, int off, int len) 将 |
Inherited methods |
|
|---|---|
java.io.Writer
|
|
java.lang.Object
|
|
java.lang.Appendable
|
|
java.io.Closeable
|
|
java.io.Flushable
|
|
java.lang.AutoCloseable
|
|
PipedWriter (PipedReader snk)
创建一个连接到指定管道读取器的管道写入器。 写入该流的数据字符将作为来自snk输入。
| Parameters | |
|---|---|
snk |
PipedReader: The piped reader to connect to. |
| Throws | |
|---|---|
IOException |
if an I/O error occurs. |
void close ()
关闭此管道输出流并释放与此流关联的所有系统资源。 此流可能不再用于写入字符。
| Throws | |
|---|---|
IOException |
if an I/O error occurs. |
void connect (PipedReader snk)
将此管道作者连接到接收器。 如果此对象已连接到某个其他管道读取器, IOException抛出IOException 。
如果 snk是未连接的管道读取器,而 src是未连接的管道作业器,则可以通过以下任一方式连接它们:
or the call:src.connect(snk)
The two calls have the same effect.snk.connect(src)
| Parameters | |
|---|---|
snk |
PipedReader: the piped reader to connect to. |
| Throws | |
|---|---|
IOException |
if an I/O error occurs. |
void flush ()
刷新此输出流并强制写出所有缓冲的输出字符。 这将通知任何读者角色在管道中等待。
| Throws | |
|---|---|
IOException |
if the pipe is closed, or an I/O error occurs. |
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. |
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. |