org.dellroad.stuff.io
Class NullModemOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.dellroad.stuff.io.NullModemOutputStream
- All Implemented Interfaces:
- Closeable, Flushable
public class NullModemOutputStream
- extends FilterOutputStream
Presents an OutputStream interface given a NullModemOutputStream.ReadCallback that can read from an
InputStream. A separate thread is created to perform the actual reading.
If data is written beyond what the reader is willing to consume, an IOException is thrown.
- Since:
- 1.0.82
NullModemOutputStream
public NullModemOutputStream(NullModemOutputStream.ReadCallback reader,
String name)
- Constructor.
- Parameters:
reader - InputStream reader callbackname - name for this instance; used to create the name of the background thread
getPipedOutputStream
protected PipedOutputStream getPipedOutputStream()
- Get the wrapped stream cast as a
PipedOutputStream.
finalize
protected void finalize()
throws Throwable
- Ensure output stream is closed when this instance is no longer referenced.
This ensures the reader thread wakes up (and exits, avoiding a memory leak) when an instance of this class
is created but never read from.
- Overrides:
finalize in class Object
- Throws:
Throwable