src/main/java/org/nustaq/serialization/simpleapi/OnHeapCoder.java
@Override
    public int toByteArray( Object o, byte arr[], int startIndex, int availableSize ) {
        out.resetForReUse();
        writeTarget.setBase(arr, startIndex, availableSize);
        try {
            out.writeObject(o);
        } catch (IOException e) {
            FSTUtil.<RuntimeException>rethrow(e);
        }
        int written = out.getWritten();
        return written;
    }
@Override
    public int toByteArray( Object o, byte arr[], int startIndex, int availableSize ) {
        out.resetForReUse();
        writeTarget.setBase(arr, startIndex, availableSize);
        try {
            out.writeObject(o);
        } catch (IOException e) {
            FSTUtil.<RuntimeException>rethrow(e);
        }
        int written = out.getWritten();
        return written;
    }
@ Override public int toByteArray ( Object o , byte arr [ ] , int startIndex , int availableSize ) { out . resetForReUse ( ) ; writeTarget . setBase ( arr , startIndex , availableSize ) ; try { out . writeObject ( o ) ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } int written = out . getWritten ( ) ; return written ; }
throws FSTBufferTooSmallExcpetion in case object does not fit into given range
Zero Copy method

@param o
@param availableSize
@throws java.io.IOException
@return number of bytes written to the memory region
throws FSTBufferTooSmallExcpetion in case object does not fit into given range Zero Copy method