public class PipedOutputStream extends PipedOutputStream
java.io.PipedOutputStream. In the
interface it only adds a constructor which allows for specifying the buffer
size. Its implementation, however, is much simpler and a lot more efficient
than its equivalent. It doesn't rely on polling. Instead it uses proper
synchronization with its counterpart be.re.io.PipedInputStream.
Multiple writers can write in this stream concurrently. The block written by
a writer is put in completely. Other writers can't come in between.| Modifier | Constructor and Description |
|---|---|
protected |
PipedOutputStream()
Creates an unconnected PipedOutputStream.
|
|
PipedOutputStream(PipedInputStream sink)
Creates a PipedOutputStream with a default buffer size and connects it to
sink. |
|
PipedOutputStream(PipedInputStream sink,
int bufferSize)
Creates a PipedOutputStream with buffer size
bufferSize and
connects it to sink. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
connect(PipedInputStream sink) |
void |
flush() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
connectprotected PipedOutputStream()
public PipedOutputStream(PipedInputStream sink)
sink.public PipedOutputStream(PipedInputStream sink, int bufferSize)
bufferSize and
connects it to sink.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class PipedOutputStreamIOException - The pipe is not connected.public void connect(PipedInputStream sink) throws IOException
IOException - The pipe is already connected.public void flush()
throws IOException
flush in interface Flushableflush in class PipedOutputStreamIOExceptionpublic void write(int b)
throws IOException
write in class PipedOutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class PipedOutputStreamIOException - The pipe is not connected or a reader has closed it.Copyright © 2023. All rights reserved.