Пример #1
0
  /**
   * Duplicate this Notify message to future injection Serialize to memory and deserialize, safe
   * way.
   *
   * @return duplicated Notify event
   */
  public Notify duplicate() throws IOException, ClassNotFoundException {
    Notify result = new Notify();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    writeExternal(oos);
    oos.close();

    byte[] buf = baos.toByteArray();
    baos.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(buf);
    ObjectInputStream ois = new ObjectInputStream(bais);

    result.readExternal(ois);
    ois.close();
    bais.close();

    return result;
  }