Here you can find the source of appendContentsTofile(String fileName, String contents)
public static void appendContentsTofile(String fileName, String contents) throws Exception
//package com.java2s; /******************************************************************************* * Copyright ? 2012-2015 eBay Software Foundation * This program is dual licensed under the MIT and Apache 2.0 licenses. * Please see LICENSE for more information. *******************************************************************************/ import java.io.RandomAccessFile; public class Main { public static void appendContentsTofile(String fileName, String contents) throws Exception { RandomAccessFile file = null; try {//from w w w . j a v a 2 s . c om file = new RandomAccessFile(fileName, "rw"); file.seek(file.length()); file.writeBytes(contents); } finally { if (file != null) file.close(); } } }