Java File Append appendFile(String path, String sb)

Here you can find the source of appendFile(String path, String sb)

Description

append File

License

Open Source License

Declaration

public static void appendFile(String path, String sb) 

Method Source Code

//package com.java2s;
/**//from   w w w .  ja v a  2s  .  c  om
 * Copyright (c) 2013 Armin T?pfer
 *
 * This file is part of ProfileSim.
 *
 * ProfileSim is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or any later version.
 *
 * ProfileSim 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * ProfileSim. If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.*;

public class Main {
    public static void appendFile(String path, String sb) {
        try {
            // Create file 
            FileWriter fstream = new FileWriter(path, true);
            try (BufferedWriter out = new BufferedWriter(fstream)) {
                out.write(sb);
            }
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error append file: ");
            System.err.println(path);
            System.err.println(sb);
        }
    }
}

Related

  1. appendFile(String filename, String text)
  2. appendFile(String filename, String text)
  3. appendFile(String fileName, StringBuffer sb)
  4. appendFile(String fullName, String text)
  5. appendFile(String path, String content)
  6. appendFile(String source, String filetoappend)
  7. appendFile(String strThrift, String filePath)
  8. appendFileBytes(String srcFileName, String tarFileName)
  9. appendFileContent(File file, String content, boolean append)