public final byte[] serialize() throws IOException {
  ByteArrayOutputStream stream=new ByteArrayOutputStream(computeSerializedSize());
  serialize(stream);
  return stream.toByteArray();
}

public final byte [ ] serialize ( ) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream ( computeSerializedSize ( ) ) ; serialize ( stream ) ; return stream . toByteArray ( ) ; }
serialize object to byte array
