Here you can find the source of appendFile(String fullName, String text)
public static boolean appendFile(String fullName, String text)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static boolean appendFile(String fullName, String text) { try {/*from w ww . ja va 2 s . c om*/ newFile(fullName); FileWriter out = new FileWriter(fullName, true); out.write(text); out.close(); } catch (Exception e) { System.out.println("error occur when creating file"); e.printStackTrace(); return false; } return true; } public static boolean newFile(String fullName) { try { File file = new File(fullName); if (!file.exists()) { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } file.createNewFile(); } } catch (Exception e) { System.out.println("error occur when creating folder"); e.printStackTrace(); return false; } return true; } public static boolean newFile(String fullName, String text) { try { newFile(fullName); FileWriter out = new FileWriter(fullName, false); out.write(text); out.close(); } catch (Exception e) { System.out.println("error occur when creating file"); e.printStackTrace(); return false; } return true; } public static void createNewFile(File f) throws IOException { if (f.exists()) { f.delete(); } f.getParentFile().mkdirs(); f.createNewFile(); } }