@Test public void testWriteCsv_null_fails() throws IOException { thrown.expect(NullPointerException.class); thrown.expectMessage("Null file name"); CsvFiles.writeCsv(dataList, null); }
public static void writeCsv(List<String[]> csvData, String fileName) throws IOException { Preconditions.checkNotNull(csvData, "Null CSV data"); Preconditions.checkNotNull(fileName, "Null file name"); CSVWriter writer = null; try { writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8)); for (String[] line : csvData) { writer.writeNext(line); } } finally { if (writer != null) { writer.close(); } } }
CsvFiles { public static void writeCsv(List<String[]> csvData, String fileName) throws IOException { Preconditions.checkNotNull(csvData, "Null CSV data"); Preconditions.checkNotNull(fileName, "Null file name"); CSVWriter writer = null; try { writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8)); for (String[] line : csvData) { writer.writeNext(line); } } finally { if (writer != null) { writer.close(); } } } }
CsvFiles { public static void writeCsv(List<String[]> csvData, String fileName) throws IOException { Preconditions.checkNotNull(csvData, "Null CSV data"); Preconditions.checkNotNull(fileName, "Null file name"); CSVWriter writer = null; try { writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8)); for (String[] line : csvData) { writer.writeNext(line); } } finally { if (writer != null) { writer.close(); } } } private  CsvFiles(); }
CsvFiles { public static void writeCsv(List<String[]> csvData, String fileName) throws IOException { Preconditions.checkNotNull(csvData, "Null CSV data"); Preconditions.checkNotNull(fileName, "Null file name"); CSVWriter writer = null; try { writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8)); for (String[] line : csvData) { writer.writeNext(line); } } finally { if (writer != null) { writer.close(); } } } private  CsvFiles(); static Map<String, String> getCsvDataMap(String fileName,
      final int key, final int value, boolean headerPresent); static Map<String, String> getCsvDataMap(String fileName, boolean headerPresent); static Map<String, String[]> getCsvDataMapArray(String fileName, boolean headerPresent); static List<Map<String, String>> getCsvDataListMap(String fileName,
      boolean headerPresent); static List<String> getCsvDataByColumn(String fileName, final int column,
      boolean headerPresent); static List<String[]> getCsvDataArray(String fileName, boolean headerPresent); static List<String[]> getCsvDataArray(Reader csvReader, boolean headerPresent); static void writeCsv(List<String[]> csvData, String fileName); }
CsvFiles { public static void writeCsv(List<String[]> csvData, String fileName) throws IOException { Preconditions.checkNotNull(csvData, "Null CSV data"); Preconditions.checkNotNull(fileName, "Null file name"); CSVWriter writer = null; try { writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8)); for (String[] line : csvData) { writer.writeNext(line); } } finally { if (writer != null) { writer.close(); } } } private  CsvFiles(); static Map<String, String> getCsvDataMap(String fileName,
      final int key, final int value, boolean headerPresent); static Map<String, String> getCsvDataMap(String fileName, boolean headerPresent); static Map<String, String[]> getCsvDataMapArray(String fileName, boolean headerPresent); static List<Map<String, String>> getCsvDataListMap(String fileName,
      boolean headerPresent); static List<String> getCsvDataByColumn(String fileName, final int column,
      boolean headerPresent); static List<String[]> getCsvDataArray(String fileName, boolean headerPresent); static List<String[]> getCsvDataArray(Reader csvReader, boolean headerPresent); static void writeCsv(List<String[]> csvData, String fileName);  }