public static void writeDocumentToFile ( Document document , String filePathname , String method , int indent ) throws TransformerException , IOException { Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "no" ) ; transformer . setOutputProperty ( OutputKeys . METHOD , method ) ; transformer . transform ( new DOMSource ( document ) , new StreamResult ( new FileOutputStream ( filePathname ) ) ) ; }
Write the document object to a file .