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;
}

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 .
