Code example for Transformer

Methods: setOutputPropertytransform

0
		TransformerFactory tfactory = TransformerFactory.newInstance();
		Transformer serializer;
		try { 
			serializer = tfactory.newTransformer();
			// Setup indenting to "pretty print" 
			serializer.setOutputProperty(OutputKeys.INDENT, "yes");
			serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
 
			serializer.transform(new DOMSource(doc), new StreamResult(out));
		} catch (TransformerException e) {
			// this is fatal, just dump the stack and throw a runtime exception 
			e.printStackTrace();
			throw new RuntimeException(e);
		} 
	} 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE