Java Text File Append fileAppend(String target, String source)

Here you can find the source of fileAppend(String target, String source)

Description

Append one file to another.

License

Open Source License

Parameter

Parameter Description
target The file that gets appended to.
source The file to append.

Declaration

static public void fileAppend(String target, String source) throws IOException 

Method Source Code

//package com.java2s;
/**/*from w w w . ja v a 2  s. c  om*/
 * Util.java
 * @author John Green
 * 27-Oct-2002
 * www.joanju.com
 * 
 * Copyright (c) 2002 Joanju Limited.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 */

import java.io.*;

public class Main {
    /** Append one file to another.
     * @param target The file that gets appended to.
     * @param source The file to append.
     */
    static public void fileAppend(String target, String source) throws IOException {
        fileThing(source, target, true);
    }

    static private void fileThing(String from, String to, boolean append) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(from));
        BufferedWriter out = new BufferedWriter(new FileWriter(to, append));
        int c;
        while ((c = in.read()) != -1)
            out.write(c);
        in.close();
        out.close();
    }
}

Related

  1. appendStringToFile(String file, String contents)
  2. appendStringToFile(String fileName, String data)
  3. appendStringToFile(String str, String oFileName)
  4. appendStringToFile(String string, String filename)
  5. FileAppend(String fileNameWithPath, String content)
  6. fileAppendString(String target, String source)