code: public void toStream(boolean skipNonOverrides, OutputStream out)
              throws Exception {
          PrintWriter writer = null;
          try {
              writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
              write(skipNonOverrides, true, writer);
          } finally {
              try {
                  writer.close();
              } catch (Throwable th) {
              }
              try {
                  out.close();
              } catch (Throwable th) {
              }
          }
      }
docs: Serialize to the given stream, closing it when finished. If
  skipNonOverrides is true, any configuration whose values are all null
  will not be written.