src/main/java/org/nustaq/serialization/FSTObjectOutput.java
public byte[] getCopyOfWrittenBuffer() {
        if ( ! getCodec().isByteArrayBased() ) {
            return getBuffer();
        }
        byte res [] = new byte[getCodec().getWritten()];
        byte[] buffer = getBuffer();
        System.arraycopy(buffer,0,res,0, getCodec().getWritten());
        return res;
    }
public byte[] getCopyOfWrittenBuffer() {
        if ( ! getCodec().isByteArrayBased() ) {
            return getBuffer();
        }
        byte res [] = new byte[getCodec().getWritten()];
        byte[] buffer = getBuffer();
        System.arraycopy(buffer,0,res,0, getCodec().getWritten());
        return res;
    }
public byte [ ] getCopyOfWrittenBuffer ( ) { if ( ! getCodec ( ) . isByteArrayBased ( ) ) { return getBuffer ( ) ; } byte res [ ] = new byte [ getCodec ( ) . getWritten ( ) ] ; byte [ ] buffer = getBuffer ( ) ; System . arraycopy ( buffer , 0 , res , 0 , getCodec ( ) . getWritten ( ) ) ; return res ; }
@return a copy of written bytes.
Warning: if the stream has been flushed, this will fail with an exception.
a flush is triggered after each 1st level writeObject.

note: in case of non-stream based serialization (directbuffer, offheap mem) getBuffer will return a copy anyways.
@return a copy of written bytes . Warning : if the stream has been flushed this will fail with an exception . a flush is triggered after each 1st level writeObject .