Java FileWriter Write saveListToFile(ArrayList list, String filePath)

Here you can find the source of saveListToFile(ArrayList list, String filePath)

Description

save List To File

License

Open Source License

Declaration

public static void saveListToFile(ArrayList<String> list,
            String filePath) 

Method Source Code

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

import java.io.File;

import java.io.FileNotFoundException;

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

import java.util.ArrayList;

public class Main {
    public static void saveListToFile(ArrayList<String> list,
            String filePath) {/*  w  w  w  . ja  va 2  s .  c om*/
        File file = new File(filePath);
        try {
            FileWriter fw = new FileWriter(file);
            for (int i = 0; i < list.size(); i++) {
                String s = list.get(i);
                fw.write(s + "\n");
                System.out.println(s);
            }
            fw.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}

Related

  1. saveInputStreamInFile(InputStream stream, FileWriter f)
  2. saveIntegerNodes2File(Integer[] nodes, String fileName)
  3. saveIntNodes2File(int[] nodes, String fileName)
  4. saveList(String listName, Set list)
  5. saveListStringToFile(String filePath, List listString)
  6. saveMap(Map map, String filePath)
  7. saveMap(String filename, Map map)
  8. saveMappingFile(File mappingFile, Map messageMap)
  9. saveMeasures(String appDirPath, String fileName, double[] measures)