Java File Append Text appendTextToFile(String filename, String data)

Here you can find the source of appendTextToFile(String filename, String data)

Description

append Text To File

License

Apache License

Declaration

public static void appendTextToFile(String filename, String data) throws IOException 

Method Source Code

//package com.java2s;
/*/*  ww w  .j  av a 2  s  . c om*/
 * Copyright 2015-2016 USEF Foundation
 *
 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.BufferedWriter;

import java.io.FileWriter;
import java.io.IOException;

import java.io.PrintWriter;

public class Main {
    public static void appendTextToFile(String filename, String data) throws IOException {
        try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)))) {
            out.println(data);
        }
    }
}

Related

  1. appendTextString(File outputFile, String doc)
  2. appendTextToFile(@Nonnull File target, String text)
  3. appendTextToFile(File fileToAppend, Set linesToAppend)
  4. appendTextToFile(String file, String text)
  5. appendTextToFile(String file_name, String text)
  6. AppendTextToFile(String filePath, String text)
  7. appendTextToFile(String text, File file)
  8. appendToFile(File destFile, InputStream source)
  9. appendToFile(File file, String data)