Java File Append appendFile(File f, String content)

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

Description

append File

License

Apache License

Declaration

public static void appendFile(File f, String content) throws Exception 

Method Source Code

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

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

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

public class Main {
    public static void appendFile(File f, String content) throws Exception {
        BufferedWriter writer = null;
        try {/*from w  w  w .  j  a  v a  2  s . co  m*/
            writer = new BufferedWriter(new FileWriter(f, true));
            writer.write(content);
        } catch (Exception e) {
            throw e;
        } finally {
            if (writer != null) {
                try {
                    writer.flush();
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. appendContent(File file, String content, String encoding)
  2. appendContentsToFile(File file, StringBuilder contents)
  3. appendContentsTofile(String fileName, String contents)
  4. appendContentToFile(File file, String fileContent)
  5. appendFile(byte[] data, String file)
  6. appendFile(File f, StringBuffer sb)
  7. appendFile(File file, String content)
  8. appendFile(File file, String url)
  9. appendFile(File filename, String data)