Java tutorial
//package com.java2s; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { public static void writeToFile(String fileName, String xml) throws IOException { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true), 1024)); out.println(xml); out.flush(); out.close(); } }