Class NullModemOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.dellroad.stuff.io.NullModemOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class NullModemOutputStream extends FilterOutputStream
Presents an OutputStream interface given a ReadCallback that can read from an InputStream.

A background process, initated by a provided Executor, invokes the ReadCallback to read from an InputStream which receives whatever is written to this OutputStream.

Exceptions

Regarding this OutputStream:

The InputStream provided to the ReadCallback should never throw any IOException, as long as it is still open.

Synchronous Close

Normally, an OutputStream will not return from close() until all data has been written out (e.g., to a destination file). However, due to internal buffering, it's possible to flush and close a NullModemOutputStream before the reader thread has finished actually reading that data. Therefore, the guarantee normally provided by close() that all of the data has been flushed and "reached its destination" (so to speak) is lost. To prevent this scenario, use setSynchronousClose(true) prior to close(), which will force close() to block until the reader thread has finished reading and returned from readFrom().

Since:
1.0.82