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文件的方法,并通过第三方包解决中文乱码问题。提供了一个具体的解析示例代码,展示了如何读取CSV文件并将其转换为List集合。
1910

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



