I was wondering if anyone could help me out with this exception I've been getting.
I have a custom class/object named MindsparkPartnerCode with two variables named ieFFCode & chromeCode.
I would like for my Selenium Java program to create an array of MindsparkPartnerCode objects, read from a CSV file, and then store the values read from the first column of that CSV file into the ieFFCode for the first object of the array, and so on until it reaches the first blank line.
However, each time I run the program, I get an ArrayIndexOutOfBoundsException at the line record.setIEFFCode(chunks[0]);
Could anyone tell me what I'm doing wrong? I'm using old code from a co-worker of mine, which is why I'm not using an "index" for the Array. Though I'd be willing to use that if it would make the code more readable.
List<MindsparkPartnerCode> records = new ArrayList<MindsparkPartnerCode>();
FileReader r = new FileReader(
"C:\\DailyLocalGuidePartnerCode.csv");
BufferedReader bfr = new BufferedReader(r);
String line = null;
try {
while ((line = bfr.readLine()) != null) {
if (StringUtils.isBlank(line))
continue;
System.out.println(line);
String[] chunks = line.split(",");
MindsparkPartnerCode record = new MindsparkPartnerCode();
record.setIEFFCode(chunks[0]);
records.add(record);
}
} finally {
bfr.close();
r.close();
}