Background: I'm trying to read from a csv file that I made with excel.
An example line of something I'm trying to read would be
Text,435,435,,,,,,,,,,,,,20,,,,,,,,,,,,,,,,,,,
My code is
BufferedReader br = null;
String line = "";
String cvsSplitBy = ",";
ArrayList<Item> itemList = new ArrayList<Item>();
try {
br = new BufferedReader(new FileReader("/Items.csv"));
br.readLine();
while ((line = br.readLine()) != null) {
// use comma as separator
String[] stats = line.split(cvsSplitBy);
for(int i =0; i<stats.length; i++){
System.out.print(i + ",");
System.out.print(stats[i] + "," + \n);
}
This gives an output of my String[]. However this gives an output of
0,Text,1,435,2,435,3,,4,,5,,6,,7,,8,,9,,10,,11,,12,,13,,14,,15,20,
An input of
Text,435,435,,,,,,,,,,1800,,,,,,,,,,,,,,,,,,,,,,
Gives:
0,Amplifying Tome,1,435,2,435,3,,4,,5,,6,,7,,8,,9,,10,,11,1800,
Why is my array stopping at the first number it finds?