public void saveFileTo(File dir) throws IOException {
    InfoResultModel info = addInfo("fileSave");
    if (files.size() == 0) {
      info.addLine("No file found to be saved.");
      setStatus(Result.Status.ERROR);
      return;
    }

    if (!dir.exists() && !dir.mkdirs()) {
      info.addLine(dir.getAbsolutePath() + " can not be created.");
      setStatus(Result.Status.ERROR);
      return;
    }
    if (!dir.isDirectory()) {
      info.addLine(dir.getAbsolutePath() + " is not a directory.");
      setStatus(Result.Status.ERROR);
      return;
    }
    if (!dir.canWrite()) {
      info.addLine("Can not write to " + dir.getAbsolutePath());
      setStatus(Result.Status.ERROR);
      return;
    }

    for (FileResultModel fileResult : files) {
      info.addLine(fileResult.saveFile(dir));
    }

  }
this saves the file data in this result model to the specified directory, and add appropriate
information to the result model to indicate the result of the file save.
this only applies to the commands that saves the file content in byte[], not download the
files over http channel
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/result/model/ResultModel.java