Java File Append appendContentsTofile(String fileName, String contents)

Here you can find the source of appendContentsTofile(String fileName, String contents)

Description

append Contents Tofile

License

MIT License

Declaration

public static void appendContentsTofile(String fileName, String contents) throws Exception 

Method Source Code

//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();
        }
    }
}

Related

  1. appendContent(File file, String content, String encoding)
  2. appendContentsToFile(File file, StringBuilder contents)
  3. appendContentToFile(File file, String fileContent)
  4. appendFile(byte[] data, String file)
  5. appendFile(File f, String content)
  6. appendFile(File f, StringBuffer sb)