See a) the API for XMLOutputFactory - the method createXMLStreamWriter takes an OutputStream to write to (currently you are using System.out) b) See FileOutputStream (Java Platform SE 6). In other...