public static Object serializeAndRecover(Object o){
  try {
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    ObjectOutputStream so=new ObjectOutputStream(bos);
    so.writeObject(o);
    ByteArrayInputStream bis=new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream si=new ObjectInputStream(bis);
    return si.readObject();
  }
 catch (  IOException ioe) {
    return null;
  }
catch (  ClassNotFoundException cnfe) {
    return null;
  }
}

public static Object serializeAndRecover ( Object o ) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ObjectOutputStream so = new ObjectOutputStream ( bos ) ; so . writeObject ( o ) ; ByteArrayInputStream bis = new ByteArrayInputStream ( bos . toByteArray ( ) ) ; ObjectInputStream si = new ObjectInputStream ( bis ) ; return si . readObject ( ) ; } catch ( IOException ioe ) { return null ; } catch ( ClassNotFoundException cnfe ) { return null ; } }
serializes an object to a bytes array and then recovers the object from the bytes array . returns the deserialized object .
