Java Text File Append appendStringToFile(final String path, final String output)

Here you can find the source of appendStringToFile(final String path, final String output)

Description

This method appends a string to a textfile

License

Open Source License

Parameter

Parameter Description
path A path to a file
output A text to write to a file

Exception

Parameter Description
IOException an exception

Declaration

public static void appendStringToFile(final String path, final String output) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    /**// w w w.  j  a va  2 s.  c o  m
     * This method appends a string to a textfile
     * 
     * @param path
     *            A path to a file
     * @param output
     *            A text to write to a file
     * @throws IOException
     */
    public static void appendStringToFile(final String path, final String output) {
        try {
            FileWriter fw = new FileWriter(path, true);
            fw.append(output);
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. add2File(String fileName, String content)
  2. appendStringToFile(File f, String s)
  3. appendStringToFile(File file, String string)
  4. appendStringToFile(File file, String string)
  5. appendStringToFile(File file, String string)
  6. appendStringToFile(String file, String contents)
  7. appendStringToFile(String fileName, String data)
  8. appendStringToFile(String str, String oFileName)
  9. appendStringToFile(String string, String filename)