Here you can find the source of appendToFile(String sb, String directory, String fileName)
public static void appendToFile(String sb, String directory, String fileName)
//package com.java2s; import java.io.*; public class Main { public static void appendToFile(String sb, String directory, String fileName) { if (!directory.endsWith("/")) { directory = directory + "/"; }/*from www . j av a2s.com*/ File out = new File(directory + fileName); //System.out.println(directory+fileName); try { Writer fw = new OutputStreamWriter(new FileOutputStream(out, true), "UTF-8"); try { fw.write(sb.toString()); fw.close(); } catch (IOException e) { e.printStackTrace(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }