Here you can find the source of copyFileWithAppend(File source, File destination)
private static void copyFileWithAppend(File source, File destination) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class Main { private static void copyFileWithAppend(File source, File destination) throws IOException { if (!destination.exists()) { destination.getParentFile().mkdirs(); destination.createNewFile(); }// w ww .ja v a2s . c o m if (!source.exists()) { throw new IOException("Source file must exist!"); } BufferedReader sourceReader = new BufferedReader(new FileReader(source)); BufferedWriter destinationWriter = new BufferedWriter(new FileWriter(destination, true)); String line; while ((line = sourceReader.readLine()) != null) { destinationWriter.write(line); destinationWriter.newLine(); } destinationWriter.flush(); destinationWriter.close(); sourceReader.close(); } }