예제 #1
0
  // move?
  public Object unserialize(String str) {
    Object object = null;
    byte[] bytes = games.distetris.domain.Base64.decode(str, games.distetris.domain.Base64.NO_WRAP);

    try {
      ByteArrayInputStream bs = new ByteArrayInputStream(bytes);
      ObjectInputStream is = new ObjectInputStream(bs);
      object = (Object) is.readObject();
      is.close();
    } catch (Exception e) {
      e.printStackTrace();
      return new String();
    }
    return object;
  }
예제 #2
0
  // move?
  public String serialize(Object object) {
    byte[] result = null;

    try {
      ByteArrayOutputStream bs = new ByteArrayOutputStream();
      ObjectOutputStream os = new ObjectOutputStream(bs);
      os.writeObject(object);
      os.close();
      result = bs.toByteArray();
    } catch (Exception e) {
      e.printStackTrace();
      return new String();
    }

    return games.distetris.domain.Base64.encodeToString(
        result, games.distetris.domain.Base64.NO_WRAP);
  }