/** Read the object from Base64 string. */
private static Object fromString(String s) throws IOException, ClassNotFoundException {
byte[] data = new BASE64Decoder().decodeBuffer(s);
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
Object o = ois.readObject();
ois.close();
return o;
}
/** Write the object to a Base64 string. */
private static String toString(Object o) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
oos.close();
return new String(new BASE64Encoder().encode(baos.toByteArray()));
}