Java File Append appendFile(String source, String filetoappend)

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

Description

append File

License

Open Source License

Declaration

public static void appendFile(String source, String filetoappend) 

Method Source Code

//package com.java2s;
// SOLUTIONS CORP. OR ITS LICENSORS.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

public class Main {
    public static void appendFile(String source, String filetoappend) {

        try {/*from  ww  w .j a  va2 s. com*/
            boolean append = true;
            File filesrc = new File(source);
            BufferedWriter output = new BufferedWriter(new FileWriter(
                    filesrc, append));

            File ftoappend = new File(filetoappend);
            BufferedReader br = new BufferedReader(
                    new FileReader(ftoappend));
            String line = br.readLine();

            while (line != null) {
                output.write(line);
                output.newLine();
                line = br.readLine();
            }
            output.close();
            br.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

Related

  1. appendFile(String filename, String text)
  2. appendFile(String fileName, StringBuffer sb)
  3. appendFile(String fullName, String text)
  4. appendFile(String path, String content)
  5. appendFile(String path, String sb)
  6. appendFile(String strThrift, String filePath)
  7. appendFileBytes(String srcFileName, String tarFileName)
  8. appendFileContent(File file, String content, boolean append)
  9. appendFileLines(String fileName, String[] data)