code: public static void writeFile(final Document input, final File output) {
          final StreamResult result = new StreamResult(new StringWriter());
  
          format(new DOMSource(input), result);
  
          try {
              new FileWriter(output).write(result.getWriter().toString());
          } catch (final IOException ioEx) {
              LOGGER.error("Problem writing XML to file.", ioEx);
          }
      }
docs: Write an XML document (formatted) to a given <code>File</code>.
  
  @param input
  The input XML document.
  @param output
  The intended <code>File</code>.