Here you can find the source of appendStringToFile(File file, String string)
public static void appendStringToFile(File file, String string)
//package com.java2s; /**//from w w w . j av a2 s . c om * Copyright 2013-2014 by ATLauncher and Contributors * * This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. * To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/. */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { public static void appendStringToFile(File file, String string) { FileWriter fw = null; BufferedWriter bw = null; PrintWriter pw = null; try { fw = new FileWriter(file, true); bw = new BufferedWriter(fw); pw = new PrintWriter(bw); pw.println(string); pw.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fw != null) { fw.close(); } if (bw != null) { bw.close(); } if (pw != null) { pw.close(); } } catch (IOException e) { e.printStackTrace(); } } } }