Here you can find the source of appendTextToFile(File fileToAppend, Set
public static void appendTextToFile(File fileToAppend, Set<String> linesToAppend) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Set; public class Main { public static void appendTextToFile(File fileToAppend, Set<String> linesToAppend) throws IOException { FileWriter writer = new FileWriter(fileToAppend, true); try (final BufferedWriter bufferWriter = new BufferedWriter(writer)) { String newline = System.getProperty("line.separator"); for (String line : linesToAppend) { bufferWriter.write(newline); bufferWriter.write(line); }// w w w .j a v a2 s . c o m } writer.close(); } }