| | |
| | | fos.close(); |
| | | |
| | | } |
| | | |
| | | public static void writeToCVS_1(String path, String[] headers, List<List<String>> data) throws Exception { |
| | | FileOutputStream fos = new FileOutputStream(path); |
| | | byte[] uft8bom = { (byte) 0xef, (byte) 0xbb, (byte) 0xbf }; |
| | | fos.write(uft8bom); |
| | | OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8"); |
| | | |
| | | CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader(headers); |
| | | CSVPrinter csvPrinter = new CSVPrinter(osw, csvFormat); |
| | | |
| | | for (int i = 0; i < data.size(); i++) { |
| | | csvPrinter.printRecord(data.get(i)); |
| | | } |
| | | |
| | | csvPrinter.flush(); |
| | | csvPrinter.close(); |
| | | osw.close(); |
| | | fos.close(); |
| | | |
| | | } |
| | | } |