public class FastPipedOutputStream extends OutputStream implements ErrorPropagatingOutputStream
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 FastPipedInputStream.FastPipedOutputStream| Constructor and Description |
|---|
FastPipedOutputStream()
Creates an unconnected PipedOutputStream.
|
FastPipedOutputStream(FastPipedInputStream sink)
Creates a PipedOutputStream with a default buffer size and connects it to
sink. |
FastPipedOutputStream(FastPipedInputStream sink,
int bufferSize)
Deprecated.
as of 1.350
bufferSize parameter is ignored.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
connect(FastPipedInputStream sink) |
void |
error(Throwable e)
Closes the stream and causes the reading
InputStream to report an error. |
protected void |
finalize() |
void |
flush() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public FastPipedOutputStream()
public FastPipedOutputStream(FastPipedInputStream sink) throws IOException
sink.IOException - It was already connected.@Deprecated public FastPipedOutputStream(FastPipedInputStream sink, int bufferSize) throws IOException
bufferSize and
connects it to sink.IOException - It was already connected.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - The pipe is not connected.public void error(Throwable e) throws IOException
ErrorPropagatingOutputStreamInputStream to report an error.
This method is somewhat like OutputStream.close(),
in that it signals the end of a stream. In addition to what the close method does,
this method will cause the InputStream.read()
method (or any other overloaded versions) to throw an
IOException with the given throwable as the cause.
InputStream will report an error only after all the data that has written
before is read. IOW, the error will not magically jump over the data that was written.
This is useful to propagate error over a pipe. If used over
a channel with the remoting library that doesn't yet support this,
or if the OutputStream isn't connecting to an InputStream,
this method behaves exactly like OutputStream.close().
If OutputStream is already closed or error state is
set, this method will be no-op.
error in interface ErrorPropagatingOutputStreame - if null, this method behaves exactly like OutputStream.close()IOExceptionpublic void connect(FastPipedInputStream sink) throws IOException
IOException - The pipe is already connected.protected void finalize()
throws Throwable
public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOException - The pipe is not connected or a reader has closed it.Copyright © 2004–2018. All rights reserved.