public class GeneiousObjectOutputStream extends ObjectOutputStream
ObjectOutputStream that tries to reduce disk space and also reduce memory usage
when the stream is read back in again later. It does this by overriding writeUTF(String) to look
for duplicate Strings that have been recently written and store a pointer to them.
The stream must be read back in using an GeneiousObjectInputStream.
It is preferable to use this class instead of using the ObjectOutputStream.writeObject(Object) method on ObjectOutputStream
because writeObject is about 20 times slower than writeUTF(String).
Also, unlike ObjectOutputStream.writeUTF(String), the writeUTF implementation in this class is not limited to Strings smaller than 65K.ObjectOutputStream.PutFieldbaseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING| Constructor and Description |
|---|
GeneiousObjectOutputStream(OutputStream out,
int historySize) |
| Modifier and Type | Method and Description |
|---|---|
void |
writeByte(int val) |
void |
writeByteArray(byte[] array)
Writes an array to this stream.
|
void |
writeInt(int val) |
void |
writeIntArray(int[] array)
Writes an array to this stream.
|
void |
writeSequence(SequenceDocument sequence,
ProgressListener progressListener)
Writes a sequence to this output stream which can be read back using
GeneiousObjectInputStream.readSequence() |
void |
writeStringOrCompactString(Object string)
Writes the given object which may either be a String or a CompactString to this output stream.
|
void |
writeUTF(String s) |
annotateClass, annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, reset, useProtocolVersion, write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeClassDescriptor, writeDouble, writeFields, writeFloat, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnsharedpublic GeneiousObjectOutputStream(OutputStream out, int historySize) throws IOException
out - the stream to write to.historySize - the number of recent Strings to store a reference to for detecting duplicates.IOException - if an IO error is encountered writing to the output streampublic void writeStringOrCompactString(Object string) throws IOException
GeneiousObjectInputStream.readStringOrCompactString().string - the string to write. It must not be null and must either be an instance of a String or a CompactString.IOException - if an IO error is encountered writing to the output streampublic void writeUTF(String s) throws IOException
writeUTF in interface DataOutputwriteUTF in class ObjectOutputStreamIOExceptionpublic void writeIntArray(int[] array)
throws IOException
array - the array to write which may be null.IOException - if an IO error is encountered writing to the output streamGeneiousObjectInputStream.readIntArray()public void writeByteArray(byte[] array)
throws IOException
array - the array to write which may be null.IOException - if an IO error is encountered writing to the output streamGeneiousObjectInputStream.readByteArray()public void writeSequence(SequenceDocument sequence, ProgressListener progressListener) throws IOException
GeneiousObjectInputStream.readSequence()sequence - the sequence to writeprogressListener - for reporting progressIOException - if we can't write it.GeneiousObjectInputStream.readSequence()public void writeInt(int val)
throws IOException
writeInt in interface DataOutputwriteInt in class ObjectOutputStreamIOExceptionpublic void writeByte(int val)
throws IOException
writeByte in interface DataOutputwriteByte in class ObjectOutputStreamIOException