Hello everyone
Iam trying to copy data from one .csv file to another .txt file in java. The csv file is like this
101, Helen Scott, 2003, Beginner, 1, 1, 2, 2, 3,
102, James Jackson, 2004, Amature, 2, 2, 3, 3, 4,
103, Tim Moore, 2005, Novice, 3, 4, 3, 3, 4,
104, Tom Smith, 2004, Expert, 4, 5, 3, 5, 4,
105, Jo Black, 2004, Amature, 4, 3, 2, 2, 1,
106, Mary Brown, 2001, Novice, 4, 4, 3, 3, 4,
107, John Black, 2006, Beginner, 1, 1, 1, 1, 2,
108, Mary Blue, 2005, Amature, 2, 2, 4, 3, 3,
109, Jonney Depp, 2007, Amature, 3, 3, 4, 2, 2,
110, Mary Black, 2005, Novice, 4, 2, 3, 3, 4,
Iam using a processingline method for that after which the processing method is called in the readfile... now the problem iam facing with is that i can get all the data into the read file except the scores and the program is indicating to me that there is a problem with my processing file but the error detail is also not very detailed... this is the error msg iam getting
Exception in thread "main" java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at CompetitorList.processLine(CompetitorList.java:288)
at CompetitorList.readFile(CompetitorList.java:255)
at Main.main(Main.java:7)
so heres the code for the procesing file...
private void processLine(String line) {
try {
String parts [] = line.split(",");
String id = parts[0];
int number = Integer.parseInt(id);
Name name = new Name(parts[1]);
String yearNum = parts[2];
yearNum = yearNum.trim();
int year = Integer.parseInt(yearNum);
String level = parts[3];
int scoreLength = parts.length - 4;
int scores[] = new int[scoreLength];
System.arraycopy(parts, 4, scores, 0, scoreLength);
XboxCompetetion s = new XboxCompetetion(number, name, year, level, scores);
this.add(s);
}
catch (NumberFormatException nfe) {
String error = "Number conversion error in '" + line + "' - "
+ nfe.getMessage();
System.out.println(error);
}
catch (ArrayIndexOutOfBoundsException air) {
String error = "Not enough items in : '" + line
+ "' index position : " + air.getMessage();
System.out.println(error);
}
}
Can someone please tell me where iam going wrong...