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 arraylist
s 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
Post a Comment