public void close() {
    try {
      dataOut.flush();
      if (trace) {
        traceDataOut.flush();
      }
    } catch (IOException ignore) {
    }
    try {
      outStream.close();
      if (trace) {
        traceOutStream.close();
      }
    } catch (IOException ex) {
      throw new GemFireIOException(
          "Could not close statArchiver file",
          ex);
    }
    if (getSampleCount() == 0) {
      // If we are closing an empty file go ahead and delete it.
      // This prevents the fix for 46917 from leaving a bunch of
      // empty gfs files around.
      deleteFileIfPossible(new File(getArchiveName()));
    }
  }
Closes the statArchiver by flushing its data to disk a closing its output stream.

@throws GemFireIOException if the archive file could not be closed.
geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java