Skip first line while reading CSV file in Java

前端 未结 8 2138
陌清茗
陌清茗 2021-02-15 00:30

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:49

    boolean isRecord = false;
    for (CSVRecord record : records) {
        if(isRecord){
            //process records here.
        }else{
            isRecord = true;
        }
    }
    

    Instead of adding counter adding flag will not hit the performance.

提交回复
热议问题