Class FastPipedOutputStream
- All Implemented Interfaces:
ErrorPropagatingOutputStream
,Closeable
,Flushable
,AutoCloseable
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
.- Author:
- WD
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates an unconnected PipedOutputStream.Creates a PipedOutputStream with a default buffer size and connects it tosink
.FastPipedOutputStream
(FastPipedInputStream sink, int bufferSize) Deprecated.as of 1.350 bufferSize parameter is ignored. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
connect
(FastPipedInputStream sink) void
Closes the stream and causes the readingInputStream
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) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
FastPipedOutputStream
public FastPipedOutputStream()Creates an unconnected PipedOutputStream. -
FastPipedOutputStream
Creates a PipedOutputStream with a default buffer size and connects it tosink
.- Throws:
IOException
- It was already connected.
-
FastPipedOutputStream
@Deprecated public FastPipedOutputStream(FastPipedInputStream sink, int bufferSize) throws IOException Deprecated.as of 1.350 bufferSize parameter is ignored.Creates a PipedOutputStream with buffer sizebufferSize
and connects it tosink
.- Throws:
IOException
- It was already connected.
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- The pipe is not connected.
-
error
Description copied from interface:ErrorPropagatingOutputStream
Closes the stream and causes the readingInputStream
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 theInputStream.read()
method (or any other overloaded versions) to throw anIOException
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 anInputStream
, this method behaves exactly likeOutputStream.close()
.If
OutputStream
is already closed or error state is set, this method will be no-op.- Specified by:
error
in interfaceErrorPropagatingOutputStream
- Parameters:
e
- if null, this method behaves exactly likeOutputStream.close()
- Throws:
IOException
-
connect
- Throws:
IOException
- The pipe is already connected.
-
finalize
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
- The pipe is not connected or a reader has closed it.
-