code: public void save(File file) throws IOException {
  
          Writer writer = null;
  
          try {
              writer = new Writer(file);
              writer.println(toPrettyString());
          } finally {
              if (writer != null) writer.close();
          }
      }
docs: Save this XML object as a XML file.
  
  @param file The output XML file.
  
  @throws IOException
  If an I/O error is occurred.