csv

Reading CSV file using BufferedReader resulting in reading alternative lines

落爺英雄遲暮 提交于 2020-11-25 03:31:25
问题 I'm trying to read a csv file from my java code. using the following piece of code: public void readFile() throws IOException { BufferedReader br = new BufferedReader(new FileReader(fileName)); lines = new ArrayList<String>(); String newLine; while ((newLine = br.readLine()) != null) { newLine = br.readLine(); System.out.println(newLine); lines.add(newLine); } br.close(); } The output I get from the above piece of code is every alternative line [2nd, 4th, 6th lines] is read and returned by