org.dellroad.stuff.io
Class NullModemInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.dellroad.stuff.io.NullModemInputStream
All Implemented Interfaces:
Closeable

public class NullModemInputStream
extends FilterInputStream

Presents an InputStream interface given a NullModemInputStream.WriteCallback that can write to an OutputStream. A separate thread is created to perform the actual writing.

Since:
1.0.74

Nested Class Summary
static interface NullModemInputStream.WriteCallback
          Callback interface used by NullModemInputStream.
 
Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
NullModemInputStream(NullModemInputStream.WriteCallback writer, String name)
          Constructor.
 
Method Summary
protected  void finalize()
          Ensure input stream is closed when this instance is no longer referenced.
protected  PipedInputStream getPipedInputStream()
          Get the wrapped stream cast as a PipedInputStream.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullModemInputStream

public NullModemInputStream(NullModemInputStream.WriteCallback writer,
                            String name)
Constructor.

Parameters:
writer - OutputStream writer callback
name - name for this instance; used to create the name of the background thread
Method Detail

getPipedInputStream

protected PipedInputStream getPipedInputStream()
Get the wrapped stream cast as a PipedInputStream.


finalize

protected void finalize()
                 throws Throwable
Ensure input stream is closed when this instance is no longer referenced.

This ensures the writer 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