Java File Append Text appendTextToFile(File fileToAppend, Set linesToAppend)

Here you can find the source of appendTextToFile(File fileToAppend, Set linesToAppend)

Description

append Text To File

License

Open Source License

Declaration

public static void appendTextToFile(File fileToAppend, Set<String> linesToAppend) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedWriter;
import java.io.File;

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

import java.util.Set;

public class Main {
    public static void appendTextToFile(File fileToAppend, Set<String> linesToAppend) throws IOException {
        FileWriter writer = new FileWriter(fileToAppend, true);
        try (final BufferedWriter bufferWriter = new BufferedWriter(writer)) {
            String newline = System.getProperty("line.separator");
            for (String line : linesToAppend) {
                bufferWriter.write(newline);
                bufferWriter.write(line);
            }// w w  w  .j  a v a2 s  .  c o  m
        }

        writer.close();
    }
}

Related

  1. appendText(File f, String text)
  2. appendText(String out, String text)
  3. appendText(String path, String text)
  4. appendTextString(File outputFile, String doc)
  5. appendTextToFile(@Nonnull File target, String text)
  6. appendTextToFile(String file, String text)
  7. appendTextToFile(String file_name, String text)
  8. appendTextToFile(String filename, String data)
  9. AppendTextToFile(String filePath, String text)