Skip first line while reading CSV file in Java

前端 未结 8 1638
别跟我提以往
别跟我提以往 2021-02-15 00:27

I am writing a parser code to read a .csv file and parse it to XML. This is the code I have and it works, except I would like it to skip the first line in the file. So I decided

8条回答
  •  我寻月下人不归
    2021-02-15 00:58

    Create a variable interation and initialize with 0. Check it as very first thing in while loop.

    String line;
    int iteration = 0;
    while ((line = br.readLine()) != null) {
        if(iteration == 0) {
            iteration++;  
            continue;
        }
        ...
        ...
    }
    

提交回复
热议问题