Java File Append LIne appendLine(String filePath, String text)

Here you can find the source of appendLine(String filePath, String text)

Description

append Line

License

LGPL

Declaration

public static void appendLine(String filePath, String text) throws Exception 

Method Source Code

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

import java.io.File;

import java.io.FileWriter;

public class Main {
    public static void appendLine(String filePath, String text) throws Exception {
        File file = new File(filePath);
        FileWriter writer = new FileWriter(file, true);
        String lineSeparator = System.getProperty("line.separator");
        if (!text.endsWith(lineSeparator)) {
            text += lineSeparator;/*from  w  w  w .j  av  a 2 s .  c  o  m*/
        }
        writer.write(text);
        writer.close();
    }
}

Related

  1. appendLine(String path, String line)
  2. appendLineInFile(String path, String lines)
  3. appendLines(File file, String[] lines)
  4. appendLines(File file, String[] lines)