code: public static boolean writeDocumentToFile(Document doc, String localFile) {
          try {
              TransformerFactory transfact = TransformerFactory.newInstance();
              Transformer trans = transfact.newTransformer();
              trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, YES);
              trans.setOutputProperty(OutputKeys.INDENT, YES);
              trans.transform(new DOMSource(doc), new StreamResult(new File(localFile)));
              return true;
          } catch (TransformerConfigurationException ex) {
              LOG.warn(ERROR_WRITING, localFile, ex);
              return false;
          } catch (TransformerException ex) {
              LOG.warn(ERROR_WRITING, localFile, ex);
              return false;
          }
      }
docs: Write the Document out to a file using nice formatting
  
  @param doc The document to save
  @param localFile The file to write to
  @return