Java BufferedReader read comma separated value(csv) file to array

Description

Java BufferedReader read comma separated value(csv) file to array

import java.io.BufferedReader;
import java.io.FileReader;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new FileReader("Main.csv"));
    String line = null;/*from   w w w .j ava  2s.  co m*/

    while ((line = br.readLine()) != null) {
      String[] values = line.split(",");
      for (String str : values) {
        System.out.println(str);
      }
    }
    br.close();
  }
}



PreviousNext

Related