Here you can find the source of appendToFile(final String text, final String urlFile)
Parameter | Description |
---|---|
text | The text to append to the file. |
urlFile | The url file. |
Parameter | Description |
---|---|
IOException | if the file does not exist or cannot be read. |
public static void appendToFile(final String text, final String urlFile) throws IOException
//package com.java2s; /*//from w w w. j a va2 s.c o m * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2008 - 2009, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class Main { /** * Append the specified text at the end of the File. * * @param text The text to append to the file. * @param urlFile The url file. * * @throws IOException if the file does not exist or cannot be read. */ public static void appendToFile(final String text, final String urlFile) throws IOException { //true means we append a the end of the file final FileWriter fw = new FileWriter(urlFile, true); final BufferedWriter output = new BufferedWriter(fw); try { output.write(text); output.newLine(); output.flush(); } finally { output.close(); } } }