public static byte[] serializeObject(final Object obj) throws IOException {
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  ObjectOutputStream objOut=null;
  try {
    objOut=new ObjectOutputStream(out);
    objOut.writeObject(obj);
    objOut.flush();
    return out.toByteArray();
  }
  finally {
    close(objOut);
  }
}

public static byte [ ] serializeObject ( final Object obj ) throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; ObjectOutputStream objOut = null ; try { objOut = new ObjectOutputStream ( out ) ; objOut . writeObject ( obj ) ; objOut . flush ( ) ; return out . toByteArray ( ) ; } finally { close ( objOut ) ; } }
convenience method to serialize a serializable object into a byte array . < p / >
