Apache Commons IO is a java library with simple IO utilities and filters. This requires the library commons-io-2.1.jar to be in classpath. The following example shows using FileUtils.write() API.
package com.bethecoder.tutorials.commons_io.tests; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; public class AppendFile { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { File file = new File("C:/Test/abcd.txt"); String data = "\nBE THE CODER \nExamples"; boolean append = true; FileUtils.write(file, data, "UTF-8", append); } }