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; //License from project: Apache License import java.io.*; public class Main { public static void appendToFile(String sb, String directory, String fileName) {/* w ww .j a v a 2s . com*/ if (!directory.endsWith("/")) { directory = directory + "/"; } File out = new File(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(); } } }