コード例 #1
0
 public void saveRunData(Run run, String name, String data) {
   File file = new File(getRunDir(run), name);
   try {
     BufferedWriter writer = new BufferedWriter(new FileWriter(file));
     writer.write(data);
     writer.close();
   } catch (Exception exp) {
     throw new IllegalArgumentException(
         "Error trying to save data to " + file.getAbsolutePath(), exp);
   }
 }
コード例 #2
0
  @Override
  public void execute(Properties props) {
    super.execute(props);

    HashMap<String, Object> jsonObj = new HashMap<String, Object>();
    for (Object k : props.keySet()) {
      String key = (String) k;
      String value = props.getProperty(key);
      jsonObj.put(key, value);
    }

    try {
      File runFile = new File(root, "run.json");
      JSONEncoder encoder = new JSONEncoder();
      BufferedWriter writer = new BufferedWriter(new FileWriter(runFile));
      encoder.encode(jsonObj, writer);
      writer.close();
    } catch (Exception exp) {
      throw new IllegalArgumentException("Unable to save run properties in root folder.");
    }
  }