public static String serialize(Serializable object) throws JobPersistenceException {
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    ObjectOutputStream oos=new ObjectOutputStream(baos);
    oos.writeObject(object);
    oos.flush();
    oos.close();
    return Base64.encode(baos.toByteArray());
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new JobPersistenceException(e.getMessage());
  }
}

public static String serialize ( Serializable object ) throws JobPersistenceException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeObject ( object ) ; oos . flush ( ) ; oos . close ( ) ; return Base64 . encode ( baos . toByteArray ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new JobPersistenceException ( e . getMessage ( ) ) ; } }
converts a serializable object into a string .
