Java Text File Save writeFile(final String nameFile, final List listMsg)

Here you can find the source of writeFile(final String nameFile, final List listMsg)

Description

Imprime a lista em uma arquivo.

License

Open Source License

Parameter

Parameter Description
nameFile a parameter
listMsg a parameter

Declaration

public static void writeFile(final String nameFile, final List<String> listMsg) 

Method Source Code


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

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.List;

public class Main {
    /**/* www. j  a  v  a2s .c o m*/
     * Imprime a lista em uma arquivo. Cada item em uma linha.
     * @param nameFile
     * @param listMsg
     */
    public static void writeFile(final String nameFile, final List<String> listMsg) {
        try {
            Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(nameFile), "utf-8"));
            for (String msg : listMsg) {
                writer.write(msg + "\n");
            }
            writer.close();
        } catch (IOException e) {
            System.err.println("Erro ao escrever resultado no arquivo de saida. " + e);
        }
    }
}

Related

  1. writeFile(final File f, final String content)
  2. writeFile(final File outputFile, final String data, final String encoding)
  3. writeFile(final String aText, final File aFile, final String aEncoding)
  4. writeFile(final String file, final String text)
  5. writeFile(final String name, final String s)
  6. writeFile(final String outputDir, final String response, final String fileName)
  7. writeFile(IFile annotationFile, StringBuffer head, String annotatedSignature, String nextLines, BufferedReader tailReader, IProgressMonitor monitor)
  8. writeFile(IFile file, final InputStream contents, final String charset, IProgressMonitor monitor)
  9. writeFile(List data, File f)