public void exportInCsv(List<MetadataTableSummary> metadataTableSummaryList, MetaSummarySchema extraSchema,
      String filename) throws IOException {
    File csvOutputFile = new File(filename);
    try (PrintWriter pw = new PrintWriter(csvOutputFile)){
      // print the header
      StringBuilder header = new StringBuilder()
          .append("Database Name, Table Name, Owner, Column Count, Partition Count, Table Type, File Format,")
          .append("Compression Type, Number of Rows, Number of Files, Size in Bytes, Partition Column Count, Array Column Count, Struct Column Count, Map Column Count");
      List<String> fields = extraSchema.getFields();
      if (!fields.isEmpty()) {
        header.append(", ").append(String.join(", ", fields));
      }
      pw.println(header);
      metadataTableSummaryList.stream().map(summary -> summary.toCSV(fields)).forEach(pw::println);
      pw.flush();
    } catch (IOException e) {
      System.out.println("IOException occurred: " + e);
      throw e;
    }
  }
Exporting the MetadataSummary in JSON format.

@param metadataTableSummaryList List of Summary Objects to be printed
@param filename                 Fully qualified name of the output file
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/metatool/MetaToolTaskMetadataSummary.java