protected byte[] writeExternalFormToBytes(Serializable o) throws IOException {
  ByteArrayOutputStream byteStream=new ByteArrayOutputStream();
  writeExternalFormToStream(o,byteStream);
  return byteStream.toByteArray();
}

protected byte [ ] writeExternalFormToBytes ( Serializable o ) throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream ( ) ; writeExternalFormToStream ( o , byteStream ) ; return byteStream . toByteArray ( ) ; }
converts a serializable or externalizable object to bytes . useful for in - memory tests of serialization
