src/main/java/org/nustaq/serialization/FSTConfiguration.java
public void encodeToStream( OutputStream out, Object toSerialize ) throws IOException {
        FSTObjectOutput objectOutput = getObjectOutput(); // could also do new with minor perf impact
        objectOutput.writeObject(toSerialize);
        int written = objectOutput.getWritten();
        out.write((written >>> 0) & 0xFF);
        out.write((written >>> 8) & 0xFF);
        out.write((written >>> 16) & 0xFF);
        out.write((written >>> 24) & 0xFF);

        // copy internal buffer to bufferedoutput
        out.write(objectOutput.getBuffer(), 0, written);
        objectOutput.flush();
    }
public void encodeToStream( OutputStream out, Object toSerialize ) throws IOException {
        FSTObjectOutput objectOutput = getObjectOutput(); // could also do new with minor perf impact
        objectOutput.writeObject(toSerialize);
        int written = objectOutput.getWritten();
        out.write((written >>> 0) & 0xFF);
        out.write((written >>> 8) & 0xFF);
        out.write((written >>> 16) & 0xFF);
        out.write((written >>> 24) & 0xFF);

        // copy internal buffer to bufferedoutput
        out.write(objectOutput.getBuffer(), 0, written);
        objectOutput.flush();
    }
public void encodeToStream ( OutputStream out , Object toSerialize ) throws IOException { FSTObjectOutput objectOutput = getObjectOutput ( ) ; // could also do new with minor perf impact objectOutput . writeObject ( toSerialize ) ; int written = objectOutput . getWritten ( ) ; out . write ( ( written >>> 0 ) & 0xFF ) ; out . write ( ( written >>> 8 ) & 0xFF ) ; out . write ( ( written >>> 16 ) & 0xFF ) ; out . write ( ( written >>> 24 ) & 0xFF ) ; // copy internal buffer to bufferedoutput out . write ( objectOutput . getBuffer ( ) , 0 , written ) ; objectOutput . flush ( ) ; }
helper to write series of objects to streams/files > Integer.MAX_VALUE.
it
- serializes the object
- writes the length of the serialized object to the stream
- the writes the serialized object data

on reader side (e.g. from a blocking socketstream, the reader then
- reads the length
- reads [length] bytes from the stream
- deserializes

@see decodeFromStream

@param out
@param toSerialize
@throws IOException
helper to write series of objects to streams / files > Integer . MAX_VALUE . it - serializes the object - writes the length of the serialized object to the stream - the writes the serialized object data