Class PipedOutputStream
java.lang.Object
java.io.OutputStream
ecmwf.common.technical.PipedOutputStream
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a piped output stream that is not yet connected to a piped input stream.Creates a piped output stream connected to the specified piped input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this piped output stream and releases any system resources associated with this stream.void
connect
(PipedInputStream snk) Connects this piped output stream to a receiver.void
flush()
Flushes this output stream and forces any buffered output bytes to be written out.void
write
(byte[] b, int off, int len) Writes len bytes from the specified byte array starting at offset off to this piped output stream.void
write
(int b) Writes the specified byte to the piped output stream.Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
PipedOutputStream
Creates a piped output stream connected to the specified piped input stream. Data bytes written to this stream will then be available as input from snk.- Parameters:
snk
- The piped input stream to connect to.- Throws:
IOException
- if an I/O error occurs.IOException
- if any.
-
PipedOutputStream
public PipedOutputStream()Creates a piped output stream that is not yet connected to a piped input stream. It must be connected to a piped input stream, either by the receiver or the sender, before being used.- See Also:
-
-
Method Details
-
connect
Connects this piped output stream to a receiver. If this object is already connected to some other piped input stream, an IOException is thrown.If snk is an unconnected piped input stream and src is an unconnected piped output stream, they may be connected by either the call:
src.connect(snk)
snk.connect(src)
- Parameters:
snk
- the piped input stream to connect to.- Throws:
IOException
- if an I/O error occurs.IOException
- if any.
-
write
Writes the specified byte to the piped output stream.Implements the write method of OutputStream.
- Specified by:
write
in classOutputStream
- Throws:
IOException
- if the pipe is broken,invalid reference
unconnected
-
write
Writes len bytes from the specified byte array starting at offset off to this piped output stream. This method blocks until all the bytes are written to the output stream.- Overrides:
write
in classOutputStream
- Throws:
IOException
- if the pipe is broken,invalid reference
unconnected
-
flush
Flushes this output stream and forces any buffered output bytes to be written out. This will notify any readers that bytes are waiting in the pipe.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.
-
close
Closes this piped output stream and releases any system resources associated with this stream. This stream may no longer be used for writing bytes.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.
-