Java OutputStreamWriter Write saveListString(List list, String filename)

Here you can find the source of saveListString(List list, String filename)

Description

save List String

License

Apache License

Declaration

public static void saveListString(List<String> list, String filename) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

import java.util.List;

public class Main {
    public static void saveListString(List<String> list, String filename) {
        BufferedWriter out;/*from  ww w .j ava2  s . c  o  m*/
        try {
            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF8"));

            for (int i = 0; i < list.size(); i++) {
                out.write((String) list.get(i) + "\n");
            }

            out.close();

        } catch (IOException ex) {
            System.err.println(ex.toString());
            System.exit(1);
        }
    }
}

Related

  1. saveFile(File file, String whatToSave, String encoding)
  2. saveFile(final File file, final String content)
  3. saveFile(String content, File f, String encoding)
  4. saveFile(String fname, String text, String encode)
  5. saveFile(String path, String msg)
  6. saveListText(String filename, List array)
  7. saveLongTxtList(long[] ids, String[] texts, String listFile)
  8. saveString(File f, String enc, String text)
  9. saveString(String string, File file, String charsetName)