<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
<version>2.0</version>
</dependency>
代码编写
CsvReader newCsvReader = new CsvReader(fileUrl,' ', Charset.forName("GBK"));
//读取表头
newCsvReader.readHeaders();
//读取到的行数内容存入到集合中
ArrayList<String> newCsvReaderList = new ArrayList<>();
//讲数据存储到集合中
while (newCsvReader.readRecord()) {
//读取一整行
newCsvReaderList.add(newCsvReader.getRawRecord());
}