Java Text File Save writeFile(final File destination, final List contents)

Here you can find the source of writeFile(final File destination, final List contents)

Description

Write the strings to the file, one per line.

License

Open Source License

Declaration

public static void writeFile(final File destination, final List<String> contents) throws IOException 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

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

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

import java.util.List;

public class Main {
    /** Write the strings to the file, one per line. */
    public static void writeFile(final File destination, final List<String> contents) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new FileWriter(destination));
        try {//w w  w .j a va  2 s. co  m
            for (String line : contents) {
                bw.write(line);
                bw.newLine();
            }
            bw.flush();
        } finally {
            bw.close();
        }
    }
}

Related

  1. writeFile(File outputFolder, String fileName, String content)
  2. writeFile(File path, File file, String content)
  3. writeFile(File path, String fileName, String fileContent)
  4. writeFile(File target, String content)
  5. writeFile(final byte[] content, final String path)
  6. writeFile(final File f, final String content)
  7. writeFile(final File outputFile, final String data, final String encoding)
  8. writeFile(final String aText, final File aFile, final String aEncoding)
  9. writeFile(final String file, final String text)