1

我正在尝试读取一个 csv 文件并将其数据复制到一个数组中。我似乎无法让它以这种方式工作,我不知道为什么。

String[] row = new String[0];
ArrayList<String[]> csv = new ArrayList<>();

String parser = "SPImages";
CSVReader reader = new CSVReader(new FileReader("C://data.csv"));
String[] nextLine;


while ((nextLine = reader.readNext()) != null){
    System.arraycopy(nextLine, 0, row, 0, nextLine.length);
}
4

1 回答 1

3

很可能目标数组(在本例中为“行”)没有源数组(在本例中为“nextLine”)那么大。与列表不同,数组不会自动调整大小。

于 2013-01-30T21:42:45.343 回答