I created xml file using java. I just want to copy the xml file which was there in console to notepad through coding not through run configuration process...... I tried using
PrintStream out = new PrintStream(new FileOutputStream("notepad.txt"));
System.setOut(out);
But the above line results in creation of notepad in particular location. But data is not copied inside the notepad. It results in empty notepad.
For creating xml: I used this below code which works fine
Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.setOutputProperty(OutputKeys.INDENT, "yes");
tf.setOutputProperty(OutputKeys.METHOD, "xml");
tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source src = new DOMSource(xmlDoc); Result dest = new StreamResult(System.out);
tf.transform(src, dest);
Anyone please help me on this....