Java FileWriter Write saveTreeStructuredGroupList(ArrayList> treeStructuredGroupList, String filePath)

Here you can find the source of saveTreeStructuredGroupList(ArrayList> treeStructuredGroupList, String filePath)

Description

save Tree Structured Group List

License

Apache License

Declaration

public static <T> void saveTreeStructuredGroupList(ArrayList<ArrayList<T>> treeStructuredGroupList,
            String filePath) 

Method Source Code

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

import java.io.BufferedWriter;

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

import java.io.PrintWriter;
import java.util.ArrayList;

public class Main {
    public static <T> void saveTreeStructuredGroupList(ArrayList<ArrayList<T>> treeStructuredGroupList,
            String filePath) {/*from w  w  w. ja v  a  2 s. c o  m*/

        PrintWriter pw = null;
        try {
            pw = new PrintWriter(new BufferedWriter(new FileWriter(filePath)), true);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
        for (ArrayList<T> list : treeStructuredGroupList) {
            StringBuilder sb = new StringBuilder(10);
            for (T element : list) {
                sb.append(element);
                sb.append("\t");
            }
            pw.println(sb.toString().trim());
        }
        pw.close();

    }

    public static void exit(int status) {
        System.exit(status);
    }
}

Related

  1. saveToFile(String location, File tempFile)
  2. saveToFile(String path, String line)
  3. saveToFile(String prefix, Reader input)
  4. saveToJson(Object object, String file)
  5. saveToTempFile(File folder, String content, String fileType)
  6. saveTxt(String line, String filename, boolean isEndSave)
  7. saveTxtFile(String fileName, String content)