且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Java中读取CSV文件时跳过第一行

更新时间:2023-09-17 23:42:04

您可以考虑放置 headerLine = br.readLine / code>在你的while循环之前,所以你消耗的标题与文件的其余部分分开。此外,您也可以考虑使用 opencsv 进行csv剖析,因为它可能会简化您的逻辑。

You might consider placing headerLine = br.readLine() before your while loop so you consume the header separately from the rest of the file. Also you might consider using opencsv for csv parsing as it may simplify your logic.