java 解析csv文件例子,采用了第三方包,csv文件 中文乱码问题
解析方法:
public List resolveCsv(String csvFileName) {
CSVReader reader = null;
String[] nextLine = null;
List resolve = new ArrayList();
try {
reader = new CSVReader(new FileReader(csvFileName));
while ((nextLine = reader.readNext()) != null) {
if (nextLine != null) {
resolve.add(nextLine);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return resolve;
}
附件中是 第三方包的源码,我有改动,
改动的地方:由原来的输入一个Reader 改成了,输入参数变为文件路径,这样解决了csv文件 中文乱码问题
本文提供了一个Java方法解析CSV文件的例子,并通过使用第三方包解决了中文乱码问题。方法包括创建CSVReader对象读取文件,处理乱码问题,并将数据添加到集合中返回。
1909

被折叠的 条评论
为什么被折叠?



