### Question:
DomUtilities extends Static { public static void write(final Document doc, final Object output) throws TransformerException, FileNotFoundException, IOException{ final Source source = new DOMSource(doc); final Result result; if(output instanceof File){ result = new StreamResult((File)output); }else if(output instanceof Writer){ result = new StreamResult((Writer)output); }else{ final OutputStream stream = toOutputStream(output); result = new StreamResult(stream); } final TransformerFactory factory = TransformerFactory.newInstance(); final Transformer trs = factory.newTransformer(); trs.setOutputProperty(OutputKeys.INDENT, "yes"); trs.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); trs.transform(source, result); } private  DomUtilities(); static Document read(final Object input); static void write(final Document doc, final Object output); static Element firstElement(final Element parent, final String tagName); static Element firstElement(final Element parent, final String tagName, final boolean recursive); static List<Element> getListElements(final Element parent, final String tagName); static List<Element> getListElementsNonRecusive(final Element parent, final String tagName); static Node getNodeByLocalName(final Node parent, final String name); static T textValue(final Element parent, final String tagName, final Class<T> clazz); static T textValue(final Element parent, final String tagName, final Class<T> clazz, final boolean recursive); static T textAttributeValue(final Element parent, final String tagName,final String attributeName, final Class<T> clazz); static T textAttributeValue(final Element parent, final String tagName,final String attributeName, final Class<T> clazz, boolean recursive); static T textValueSafe(final Element parent, final String tagName, final Class<T> clazz); static T textValueSafe(final Element parent, final String tagName, final Class<T> clazz, final boolean recusive); static T textAttributeValueSafe(final Element parent, final String tagName, final String attributeName, final Class<T> clazz); static T textAttributeValueSafe(final Element parent, final String tagName, final String attributeName, final Class<T> clazz, final boolean recursive); static void prettyPrint(Path input, Path output);  }### Answer:
@Test public void writeTest() throws ParserConfigurationException, IOException, TransformerException{ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder builder = factory.newDocumentBuilder(); final Document document = builder.newDocument(); document.setXmlVersion("1.0"); document.setXmlStandalone(true); final Element root = document.createElement("logs"); final Element personne = document.createElement("user"); personne.setAttribute("id","gfsd-589"); root.appendChild(personne); final Element nom = document.createElement("name"); nom.setTextContent("tom"); personne.appendChild(nom); final Element age = document.createElement("age"); age.setTextContent("45"); personne.appendChild(age); document.appendChild(root); File f = File.createTempFile("test", ".xml"); f.deleteOnExit(); DomUtilities.write(document, f); }