Here you can find the source of appendFile(File targetFile, String text)
Parameter | Description |
---|---|
targetFile | the file to append the data String to |
text | some String |
Parameter | Description |
---|---|
IOException | if an error occurred while appending the data |
public static void appendFile(File targetFile, String text) throws IOException
//package com.java2s; /*// ww w. j a va 2s . co m * Copyright (C) 2007 Roland Krueger * * Created on 26.03.2010 * * Author: Roland Krueger (www.rolandkrueger.info) * * This file is part of RoKlib. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { /** * Appends the given String to the end of a file. * * @param targetFile * the file to append the data String to * @param text * some String * @throws IOException * if an error occurred while appending the data */ public static void appendFile(File targetFile, String text) throws IOException { BufferedWriter writer = new BufferedWriter(new FileWriter(targetFile)); writer.append(text); writer.flush(); writer.close(); } }