You want j < line.length
and not <=
. If there are 10
elements in an Array then there is not an item at index 10
- you only have 0-9
.
Further using loads of variables and assigning them is not the preferred way to parse CSV. Java is an Object Orientated language.
Use an Object
to represent each line and bind the line using the opencsv javabean API