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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionvoidclose()voidconnect(FastPipedInputStream sink) voidCloses the stream and causes the readingInputStreamto report an error.protected voidfinalize()voidflush()voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(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 sizebufferSizeand connects it tosink.- Throws:
IOException- It was already connected.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- The pipe is not connected.
-
error
Description copied from interface:ErrorPropagatingOutputStreamCloses the stream and causes the readingInputStreamto 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 anIOExceptionwith the given throwable as the cause.InputStreamwill 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
OutputStreamisn't connecting to anInputStream, this method behaves exactly likeOutputStream.close().If
OutputStreamis already closed or error state is set, this method will be no-op.- Specified by:
errorin 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:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException- The pipe is not connected or a reader has closed it.
-