public class PipedOutputStream extends OutputStream
PipedOutputStream由一个线程对象和数据被从连接读取PipedInputStream通过一些其它线程。
不建议尝试从单个线程使用这两个对象,因为它可能会使线程死锁。
管被说成是broken如果从连接读取数据字节的螺纹管道输入流不再存活。
PipedInputStream
| Constructor and Description |
|---|
PipedOutputStream()
创建一个尚未连接到管道输入流的管道输出流。
|
PipedOutputStream(PipedInputStream snk)
创建连接到指定管道输入流的管道输出流。
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭此管道输出流,并释放与此流相关联的任何系统资源。
|
void |
connect(PipedInputStream snk)
将此管道输出流连接到接收器。
|
void |
flush()
刷新此输出流并强制任何缓冲的输出字节被写出。
|
void |
write(byte[] b, int off, int len)
从指定的字节数组写入
len个字节,从偏移量
off开始输出到这个管道输出流。
|
void |
write(int b)
写入指定
byte到管道输出流。
|
writepublic PipedOutputStream(PipedInputStream snk) throws IOException
snk 。
snk - 连接到的管道输入流。
IOException - 如果发生I / O错误。
public PipedOutputStream()
public void connect(PipedInputStream snk) throws IOException
IOException 。
如果snk是未连接的管道输入流,并且src是未连接的管道输出流,则可以通过以下任一方式连接它们:
或电话:src.connect(snk)
两个电话有相同的效果。snk.connect(src)
snk - 连接到管道输入流。
IOException - 如果发生I / O错误。
public void write(int b)
throws IOException
byte到管道输出流。
实现write方法OutputStream 。
write在类别
OutputStream
b -
byte 。
IOException -如果管道是
broken ,
unconnected ,关闭,或者如果发生I / O错误。
public void write(byte[] b,
int off,
int len)
throws IOException
len字节,从偏移量off开始off到这个管道输出流。
该方法阻塞直到所有字节被写入输出流。
write在类别
OutputStream
b - 数据。
off - 数据中的起始偏移量。
len - 要写入的字节数。
IOException -如果管道是
broken ,
unconnected ,关闭,或者如果发生I / O错误。
public void flush()
throws IOException
flush在界面
Flushable
flush在类别
OutputStream
IOException - 如果发生I / O错误。
public void close()
throws IOException
close在界面
Closeable
close在界面
AutoCloseable
close在类别
OutputStream
IOException - 如果发生I / O错误。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.