I am getting an error with my code and I don't understand why. I am using OpenCsv library and trying to save my CSV into an array. The CSV has Columns that look like: Date, Sold, Code and then information under it like: 1123, may4, 0021;3323;
My code is:
private static final String SAMPLE_CSV ="C:\\Users\\Documents\\o.csv\\";
public static void main(String[] args) throws IOException{
{
try (
Reader reader = Files.newBufferedReader(Paths.get(SAMPLE_CSV));
CSVReader csvReader = new CSVReader(reader);
) {
// Reading Records One by One in a String array
String[] nextRecord;
while ((nextRecord = csvReader.readNext()) != null) {
System.out.println("Order num : " + nextRecord[0]);
System.out.println("SoldToAct : " + nextRecord[1]);
System.out.println("RequestedDelivery : " + nextRecord[2]);
System.out.println("BaseCode : " + nextRecord[3]);
System.out.println("Option Code : " + nextRecord[4]);
System.out.println("==========================");
}
}
the error is in the CSVReader csvReader = new CSVReader(reader); line.