-1

我有以下代码:

    try (CSVReader reader = new CSVReader(new FileReader(file))) {
            List<String[]> r = reader.readAll();
            r.forEach(x -> System.out.println(Arrays.toString(x)));
        }
4

2 回答 2

0
    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));
   }
}
于 2021-04-07T08:12:17.230 回答
0
for (String[] s: r) {
    System.out.println(Arrays.toString(x));
}
于 2021-04-07T08:19:09.170 回答