Java File Append Text appendText(File f, String text)

Here you can find the source of appendText(File f, String text)

Description

append Text

License

Open Source License

Declaration

public static void appendText(File f, String text) 

Method Source Code


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

import java.io.BufferedWriter;
import java.io.File;

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

public class Main {

    public static void appendText(File f, String text) {
        try (FileWriter fw = new FileWriter(f, true);
                BufferedWriter bw = new BufferedWriter(fw);
                PrintWriter out = new PrintWriter(bw)) {
            out.println();//from  w  ww . j  a  v  a 2  s .com
            out.print(text);
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }
    }
}

Related

  1. appendText(String out, String text)
  2. appendText(String path, String text)
  3. appendTextString(File outputFile, String doc)
  4. appendTextToFile(@Nonnull File target, String text)