Java File Append appendFile(String file, String content)

Here you can find the source of appendFile(String file, String content)

Description

Append 'content' in 'dir'/'file'

License

Open Source License

Declaration

public static void appendFile(String file, String content) 

Method Source Code


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

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;

public class Main {
    /**//ww w.  j ava2s . c  o  m
     * Append 'content' in 'dir'/'file'
     */
    public static void appendFile(String file, String content) {
        try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true)))) {
            out.println(content);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. appendFile(final String filename, final String content)
  2. appendFile(final String name, final String s)
  3. appendFile(OutputStream output, File source)
  4. appendFile(String content, File file)
  5. appendFile(String file, byte[]... data)
  6. appendFile(String file, String text)
  7. appendFile(String fileContents, File toFile)
  8. appendFile(String fileName, byte[] data)
  9. appendFile(String fileName, String content)