There are any number of ways to do this. In the simplest case you can just use the classes in the java.io package (FileWriter etc.). For more complex data, a library such as XOM, JDOM, dom4j, etc. could do that too, or, if you don't want any external libraries, you can use the JRE's built-in DOM classes:
http://www.genedavis.com/library/xml/java_dom_xml_creation.jsp