Here you can find the source of appendContentToFile(File file, String fileContent)
Parameter | Description |
---|---|
file | file in which content to be written |
fileContent | content of the file |
Parameter | Description |
---|---|
IOException | an exception |
public static void appendContentToFile(File file, String fileContent) throws IOException
//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(); } }