List<First> listfirst(String dir){
try {
List<First> list=new ArrayList<First>();
CSVReader reader = new CSVReader(new FileReader(dir));
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
// nextLine[] is an array of values from the line
list.add(new First(nextLine[0], nextLine[1], nextLine[2],nextLine[3], nextLine[4],nextLine[5], nextLine[6], nextLine[7]));
}
return list;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
共有 1994 行。但这段代码只打印 388 行。我能做什么?
最佳答案
这就是我建议的阅读内容:
读取文件
import au.com.bytecode.opencsv.CSVReadProc;
import java.util.Arrays;
csv.read("example.csv", new CSVReadProc() {
public void procRow(int rowIndex, String... values) {
System.out.println(rowIndex + ": " + Arrays.asList(values));
}
});
关于java - 使用 opencsv 读取 csv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27060828/