Java File Append Text appendToFile(String filePath, String content)

Here you can find the source of appendToFile(String filePath, String content)

Description

append To File

License

Apache License

Parameter

Parameter Description
filePath a parameter
content a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void appendToFile(String filePath, String content) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    private static final String LINE_BREAK = "\n";

    /**/*w ww. j a va 2 s.  co m*/
     * @param filePath
     * @param content
     * @throws IOException
     */
    public static void appendToFile(String filePath, String content) throws IOException {
        BufferedWriter bw;
        bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath, true)));
        bw.write(content + LINE_BREAK);
        bw.flush();
        bw.close();
    }
}

Related

  1. appendToFile(String filename, String content, int line)
  2. appendToFile(String filename, String str)
  3. appendToFile(String filename, String text)
  4. appendToFile(String fileName, String text)
  5. appendToFile(String filename, String text)
  6. appendToFile(String filePath, String data)
  7. appendToFile(String filepath, String newLine)
  8. appendToFile(String sb, String directory, String fileName)
  9. appendToFile(String str, String filename, boolean appendNewLine)