Java - Splitting a CSV file into an Array

前端 未结 4 1566
别跟我提以往
别跟我提以往 2021-01-19 14:38

I have managed to split a CSV file based on the commas. I did this by placing a dummy String where ever there was a \',\' and then splitting based on the dummy String.

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-19 15:12

    I don't see why you need a dummy string. Why not split on comma?

    BufferedReader in = new BufferedReader(new FileReader("file.csv"));
    String line;
    while ((line = in.readLine()) != null) {
        String[] fields = line.split(",");
    }
    

提交回复
热议问题