Ejemplo n.º 1
0
 /** Write the object to a Base64 string. */
 public static String ObjectToString(Serializable o) throws IOException {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   ObjectOutputStream oos = new ObjectOutputStream(baos);
   oos.writeObject(o);
   oos.close();
   return new String(Base64Coder.encode(baos.toByteArray()));
 }
Ejemplo n.º 2
0
 /** Read the object from Base64 string. */
 public static Object ObjectFromString(String s) throws IOException, ClassNotFoundException {
   byte[] data = Base64Coder.decode(s);
   ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
   Object o = ois.readObject();
   ois.close();
   return o;
 }