Package edu.caltech.nanodb.server
Class ForwardingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- edu.caltech.nanodb.server.ForwardingOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class ForwardingOutputStream extends java.io.ByteArrayOutputStream
This class is a simple output-stream that can be used by aPrintStream
to buffer up printed output. When this stream is flushed, it causes the accumulated contents to be sent across anObjectOutputStream
. This allows the underlyingObjectOutputStream
to be used both for sending data objects, and strings of printed output.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.ObjectOutputStream
objectOutput
The underlying output stream over which objects are serialized.
-
Constructor Summary
Constructors Constructor Description ForwardingOutputStream(java.io.ObjectOutputStream objectOutput)
Construct a forwarding output-stream that will send objects over the specified object output-stream when flushed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
When called, this output stream will convert its accumulated data into aString
object, which will then be sent over the underlying object output-stream.
-
-
-
Method Detail
-
flush
public void flush() throws java.io.IOException
When called, this output stream will convert its accumulated data into aString
object, which will then be sent over the underlying object output-stream. Once this is completed, the buffered string data is cleared.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
- if an error occurs while sending the string data
-
-