Here you can find the source of appendToFile(List
public static void appendToFile(List<String> strList, File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.Closeable; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.List; public class Main { public static void appendToFile(List<String> strList, File file) throws IOException { if ((strList == null) || (strList.isEmpty()) || (file == null)) { return; }// www .jav a 2s .c o m BufferedWriter bw = null; try { bw = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true))); for (String str : strList) { bw.write(str); bw.newLine(); } } finally { close(bw); } } public static void close(Closeable stream) { if (stream == null) { return; } try { stream.close(); } catch (IOException ioe) { } } public static void close(Closeable... streams) { if ((streams == null) || (streams.length == 0)) { return; } for (Closeable c : streams) { try { if (c != null) { c.close(); } } catch (IOException ioe) { } } } }