Java Text File Save writeFile(List strList, String fileFullPath)

Here you can find the source of writeFile(List strList, String fileFullPath)

Description

write File

License

Open Source License

Declaration

public static void writeFile(List<String> strList, String fileFullPath) 

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.List;

public class Main {
    /**/* ww  w.ja  v a2s . c o  m*/
     * LINE_SEPARATOR<br/>
     * windows:\r\n
     */
    public static final String LINE_SEPARATOR = System.getProperty("line.separator");

    public static void writeFile(List<String> strList, String fileFullPath) {
        try {
            File writeFile = new File(fileFullPath);
            new File(writeFile.getParent()).mkdirs();
            writeFile.createNewFile();
            BufferedWriter out = new BufferedWriter(new FileWriter(writeFile));

            for (String str : strList) {
                out.write(str + LINE_SEPARATOR);
            }
            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeFile(IFile annotationFile, StringBuffer head, String annotatedSignature, String nextLines, BufferedReader tailReader, IProgressMonitor monitor)
  2. writeFile(IFile file, final InputStream contents, final String charset, IProgressMonitor monitor)
  3. writeFile(List data, File f)
  4. writeFile(List fileLines, String pathname)
  5. writeFile(List lines, String filePath)
  6. writeFile(List txtList, String MyFilePath)
  7. writeFile(String file, String content)
  8. writeFile(String file, String text)
  9. writeFile(String filePath, List lines)