我有以下代码:
try (CSVReader reader = new CSVReader(new FileReader(file))) {
List<String[]> r = reader.readAll();
r.forEach(x -> System.out.println(Arrays.toString(x)));
}
try (CSVReader reader = new CSVReader(new FileReader(file))) {
List<String[]> r = reader.readAll();
for(int i =0;i< r.size() ; i++){
System.out.println(Arrays.toString(r.get(i));
}
}
另一个解决方案:
try (CSVReader reader = new CSVReader(new FileReader(file))) {
List<String[]> r = reader.readAll();
for(String[] x : r){
System.out.println(Arrays.toString(x));
}
}
for (String[] s: r) {
System.out.println(Arrays.toString(x));
}