static final public byte[] serialize(final Object obj){
  final ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    final ObjectOutputStream oos=new ObjectOutputStream(baos);
    oos.writeObject(obj);
    oos.flush();
    oos.close();
  }
 catch (  Exception ex) {
    throw new RuntimeException(ex);
  }
  return baos.toByteArray();
}

static final public byte [ ] serialize ( final Object obj ) { final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { final ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeObject ( obj ) ; oos . flush ( ) ; oos . close ( ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } return baos . toByteArray ( ) ; }
serialize an object using the java serialization mechanisms .
