Hi, I currently have some code that reads an xml file and prints it out to the dos prompt screen. However, can someone tell me how I can print the whole output to a file? I know how to simply print something to a file, but I don't know how to get this xml to a file. **I have pasted code below, thanks
Thanks so much,
Carmen
********** code***********
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
public class JDomPractice {
public static void main(
String[] args) {
// Assume filename argument
String filename = args[0];
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try {
// Build the document with SAX and Xerces, no validation
SAXBuilder builder = new SAXBuilder();
// Create the document
Document
doc = builder.build(new File(filename));
// Output the document, use standard formatter
XMLOutputter fmt = new XMLOutputter();
fmt.output(doc, System.out);
/*
out = new FileOutputStream("myfile.txt");
// Connect print stream to the output stream
p = new PrintStream( out );
p.println ("This is written to a file");
p.close();
*/
} catch (Exception e) {
e.printStackTrace();
}
}
}