public byte [ ] serialize ( ) { if ( currentByteArrayIndex == 0 ) { return new byte [ 0 ] ; } final byte [ ] extractedSerializedData = new byte [ currentByteArrayIndex ] ; System . arraycopy ( serializedData , 0 , extractedSerializedData , 0 , currentByteArrayIndex ) ; return extractedSerializedData ; }
Finishes serialization returning the object as a byte array .