Here you can find the source of appendFileContent(File file, String content, boolean append)
Parameter | Description |
---|---|
file | a parameter |
content | a parameter |
append | if true, then bytes will be written to the end of the file rather than the beginning |
Parameter | Description |
---|---|
IOException | an exception |
public static void appendFileContent(File file, String content, boolean append) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2010, 2014 SAP AG and others. * 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 * * Contributors:/* w ww. ja v a 2s.c om*/ * Mathias Kinzler (SAP AG) - initial implementation *******************************************************************************/ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; public class Main { /** * Appends content to given file. * * @param file * @param content * @param append * if true, then bytes will be written to the end of the file * rather than the beginning * @throws IOException */ public static void appendFileContent(File file, String content, boolean append) throws IOException { Writer fw = null; try { fw = new OutputStreamWriter(new FileOutputStream(file, append), "UTF-8"); fw.append(content); } finally { if (fw != null) fw.close(); } } }