Here you can find the source of appendTo(String fileName, String str)
public static synchronized void appendTo(String fileName, String str) throws NullPointerException, IOException
//package com.java2s; /***************************************************************************** * The contents of this file are subject to the Ricoh Source Code Public * License Version 1.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.risource.org/RPL// w w w. j a v a2s . c o m * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * This code was initially developed by Ricoh Innovations, Inc. Portions * created by Ricoh Innovations, Inc. are Copyright (C) 1995-1999. All * Rights Reserved. * * Contributor(s): * ***************************************************************************** */ import java.io.*; public class Main { /** * Append a String to a file. * */ public static synchronized void appendTo(String fileName, String str) throws NullPointerException, IOException { RandomAccessFile f = null; if (str == null) return; try { f = new RandomAccessFile(fileName, "rw"); long length = f.length(); f.seek(length); f.write(str.getBytes()); } catch (NullPointerException e1) { // bad file name throw e1; } catch (IOException e2) { throw e2; } finally { if (f != null) try { f.close(); } catch (IOException e3) { throw e3; } } } }