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 appendOneline(String fileName, String oneline) { PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true))); out.print(oneline + "\n"); } catch (IOException e) { e.printStackTrace(); } finally { if (out != null) { out.close(); } } } }