Java File Append appendContentToFile(File file, String fileContent)

Here you can find the source of appendContentToFile(File file, String fileContent)

Description

Append file contents into specified file

License

Open Source License

Parameter

Parameter Description
file file in which content to be written
fileContent content of the file

Exception

Parameter Description
IOException an exception

Declaration

public static void appendContentToFile(File file, String fileContent) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2000, 2011. 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
 * /*from  w  ww  .j a  va 2 s.c  o  m*/
 * Contributors: 
 *       Fizer Khan, Yasmine - initial API and implementation
 *******************************************************************************/

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

import java.io.FileWriter;

import java.io.IOException;

public class Main {
    /**
     * Append file contents into specified file
     * 
     * @param file
     *            file in which content to be written
     * @param fileContent
     *            content of the file
     * @throws IOException
     */
    public static void appendContentToFile(File file, String fileContent) throws IOException {
        BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
        out.write(fileContent);
        out.close();
    }
}

Related

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