file - Using BufferedReader to read a single line in Java -


i have code reading csv. when try use filereader read solo line, makes code stop working.

here code:

try {     string line = "";     filereader = new bufferedreader(new filereader(filename));      while ((line = filereader.readline()) != null) {         string[] tokens = line.split(delimiter);         (string token : tokens) {             totaldata.add(token);             if (!artists.contains(token)) {                 artists.add(token);             }         }         (int l = 0; l <= 999; l++) {             linedata = filereader.readline();             linearray[l] = linedata;         }      } } {     filereader.close(); } 

when try read arraylist sizes , print data arraylists above code below makes stop working:

for (int l = 0; l <= 80; l++) {     linedata = filereader.readline();     linearray[l] = linedata; } 

if comment loop, fine. need loop, how can edit code resolve issue? also, happening?

for (int l = 0; l <= 80; l++) {     linedata = filereader.readline();     linearray[l] = linedata; } 

this hard code can replace single line of code:

linearray[i++] = line; 

i corrected code , that's happened:

string line = ""; int = 0; try (bufferedreader filereader = new bufferedreader(new filereader(""))) {     while ((line = filereader.readline()) != null) {         linearray[i++] = line;         string[] tokens = line.split(delimiter);         (string token : tokens) {             totaldata.add(token);             if (!artists.contains(token)) {                 artists.add(token);             }         }     } } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -