public class AutoFlushingObjectWriter extends java.lang.Object implements ObjectWriter
ObjectOutputStream immediately after calling
it's ObjectOutputStream.writeObject(Object) method.| Modifier and Type | Field and Description |
|---|---|
private java.io.ObjectOutputStream |
objectOutputStream |
private int |
resetFrequency |
private int |
writeCounter |
| Constructor and Description |
|---|
AutoFlushingObjectWriter(java.io.ObjectOutputStream objectOutputStream,
int resetFrequency)
Creates a new instance for the given
ObjectOutputStream. |
| Modifier and Type | Method and Description |
|---|---|
private void |
preventMemoryLeak()
Failing to reset the object output stream every now and then creates a serious memory leak which
is why the underlying stream will be reset according to the
resetFrequency. |
void |
write(java.lang.Object object)
Writes an object to an output.
|
private final java.io.ObjectOutputStream objectOutputStream
private final int resetFrequency
private int writeCounter
public AutoFlushingObjectWriter(java.io.ObjectOutputStream objectOutputStream,
int resetFrequency)
ObjectOutputStream.objectOutputStream - the stream to write toresetFrequency - the frequency with which the given stream will be
automatically reset to prevent a memory leakpublic void write(java.lang.Object object)
throws java.io.IOException
ObjectWriterwrite in interface ObjectWriterobject - the Object to writejava.io.IOException - in case input/output fails, details are defined by the implementationprivate void preventMemoryLeak()
throws java.io.IOException
resetFrequency.java.io.IOException