I had the following exception with the following code
package util; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import play.Logger; import au.com.bytecode.opencsv.CSVReader; public class CSVReaderUtil { public static ArrayList> readCSVFile (String fileName) { CSVReader csvReader = null; ArrayList > csvDataList = new ArrayList<>(); try { csvReader = new CSVReader(new FileReader(fileName)); String[] row; while ((row = csvReader.readNext()) != null) { csvDataList.add((ArrayList)Arrays.asList(row)); } } catch (Exception e) { Logger.error("Error: ", e); } finally { if(null != csvReader) { try { csvReader.close(); } catch (Exception e) { } } } return csvDataList; } }
- > stuff = new ArrayList
- >();
which will allow to add whatever comes out of the Arrays.asList(..) method.
No comments:
Post a Comment