Here you can find the source of AppendLineToFile(String filePath, String text)
Parameter | Description |
---|---|
filePath | Absolute file path |
text | Text to append |
Parameter | Description |
---|---|
Exception | an exception |
public static void AppendLineToFile(String filePath, String text) throws Exception
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.*; public class Main { /** Appends a line to an existing file (incuding a new line character). *//www. j a v a 2 s .c o m * @param filePath Absolute file path * @param text Text to append * @throws Exception */ public static void AppendLineToFile(String filePath, String text) throws Exception { AppendTextToFile(filePath, text + "\n"); } /** Convenience method that appends text to an existing file. * * @param filePath Absolute file path * @param text Text to append * @throws Exception */ public static void AppendTextToFile(String filePath, String text) throws Exception { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filePath, true))); out.write(text); out.close(); } }