Hi.
I've built a program to create a large DOM tree from a database. I need to be able to write this dom tree out to a file as XML, and i have only found code to send it to system.out(). Is there a way i can re-direct this to a file??? Here is the chunk of code i'm using:
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(DOM);
StreamResult result = new StreamResult(System.out); //Here it is!!!
transformer.transform(source, result);
}
etc.....
At the moment, i can create a file like this:
$
java myProgram > file.xml
But i'd rather specify a file name as an argument to the command.
Many thanks for any help!!!
Robin