public void save ( Media media ) { Check . notNull ( media ) ; try ( OutputStream output = media . getOutputStream ( ) ) { final Transformer transformer = DocumentFactory . createTransformer ( ) ; normalize ( NORMALIZE ) ; writeString ( Constant . XML_HEADER , Constant . ENGINE_WEBSITE ) ; final DOMSource source = new DOMSource ( root ) ; final StreamResult result = new StreamResult ( output ) ; final String yes = "yes" ; transformer . setOutputProperty ( OutputKeys . INDENT , yes ) ; transformer . setOutputProperty ( OutputKeys . STANDALONE , yes ) ; transformer . setOutputProperty ( PROPERTY_INDENT , "4" ) ; transformer . transform ( source , result ) ; } catch ( final TransformerException | IOException exception ) { throw new LionEngineException ( exception , media , ERROR_WRITING ) ; } }
Save an XML tree to a file .