public PersistentEtmState load() {
   PersistentEtmState state = null;
   File file = new File(path, filename);
   if (file.exists()) {
     if (file.canRead()) {
       ObjectInputStream in = null;
       try {
         in = new ObjectInputStream(new FileInputStream(file));
         state = (PersistentEtmState) in.readObject();
       } catch (Exception e) {
         // ignored
         LOG.warn("Error loading state from file " + file.getAbsolutePath(), e);
       } finally {
         if (in != null) {
           try {
             in.close();
           } catch (IOException e) {
             // ignored
           }
         }
       }
     }
   }
   return state;
 }
  private void backupFile(File aDest) {
    File backup = new File(aDest.getAbsolutePath() + ".saved");

    ObjectInputStream in = null;
    ObjectOutputStream out = null;

    try {
      in = new ObjectInputStream(new FileInputStream(aDest));
      out = new ObjectOutputStream(new FileOutputStream(backup));
      out.writeObject(in.readObject());
    } catch (Exception e) {
      LOG.warn("Error writing backup file " + aDest.getAbsolutePath(), e);
    } finally {
      try {
        if (in != null) {
          in.close();
        }
      } catch (IOException e) {
        // ingored
      }

      try {
        if (out != null) {
          out.close();
        }
      } catch (IOException e) {
        // ignored
      }
    }
  }
  public void store(PersistentEtmState state) {
    if (!path.exists()) {
      if (!path.mkdirs()) {
        LOG.warn("Unable to create destination path " + path.getAbsolutePath() + ". Aborting.");
        return;
      }
    }

    File destination = new File(path, filename);
    if (destination.exists()) {
      backupFile(destination);
      if (!destination.delete()) {
        LOG.warn(
            "Unable to delete existing destination target "
                + destination.getAbsolutePath()
                + ". Aborting.");
      }
    }

    ObjectOutputStream out = null;

    try {
      out = new ObjectOutputStream(new FileOutputStream(destination));
      out.writeObject(state);
    } catch (Exception e) {
      // ignored
      LOG.warn("Error writing state to file " + destination.getAbsolutePath(), e);
    } finally {
      if (out != null) {
        try {
          out.close();
        } catch (IOException e) {
          // ignored
        }
      }
    }
  }