Here you can find the source of appendTextToFile(String file, String text)
Parameter | Description |
---|---|
file | The filename (with full path) to write to |
text | Text to appendto the file |
public static final void appendTextToFile(String file, String text)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { /**/*from w w w . ja v a 2 s.c om*/ * Simple method to append text to a file * @param file The filename (with full path) to write to * @param text Text to appendto the file */ public static final void appendTextToFile(String file, String text) { try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true))); out.print(text); out.close(); } catch (IOException e) { e.printStackTrace(); } } }