Java File Append Text appendToFile(String filepath, String newLine)

Here you can find the source of appendToFile(String filepath, String newLine)

Description

Append string to file in a new line

License

Open Source License

Parameter

Parameter Description
filepath - path to file to append to
newLine - new line to append

Exception

Parameter Description
IOException - if there is an error opening the file

Declaration

public static void appendToFile(String filepath, String newLine)
        throws IOException 

Method Source Code

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

import java.io.*;

public class Main {
    /**//from   w ww . j  av a2  s . c o  m
     * Append string to file in a new line
     * @param filepath - path to file to append to
     * @param newLine - new line to append
     * @throws IOException - if there is an error opening the file
     */
    public static void appendToFile(String filepath, String newLine)
            throws IOException {
        FileWriter fstream = new FileWriter(filepath, true);
        PrintWriter out = new PrintWriter(fstream);
        out.println(newLine);
        //Close the output stream
        out.close();
    }
}

Related

  1. appendToFile(String filename, String text)
  2. appendToFile(String fileName, String text)
  3. appendToFile(String filename, String text)
  4. appendToFile(String filePath, String content)
  5. appendToFile(String filePath, String data)
  6. appendToFile(String sb, String directory, String fileName)
  7. appendToFile(String str, String filename, boolean appendNewLine)
  8. appendToFile(String string, File file)
  9. appendToFile(String text, String fileName)