title: How to Read large size csv file and split each line to string array in java
body: <p>i have GB of size csv file , i'am able to read this but when splitting it to an array then printing cause ArrayIndexOutOfBoundsException 
  this is my program</p>
  
  <pre><code>FileInputStream inputStream = null;
  Scanner sc = null;
  try {
  inputStream = new FileInputStream("file.csv");
  sc = new Scanner(inputStream, "UTF-8");
  int j=0;
  while (sc.hasNextLine()) {
  String[] data=new String[4]; 
  String line=sc.nextLine();
  data=line.split(",");
  System.out.println(data[0]+" "+data[1]+" "+data[2]+" "+data[3]);
  }
  if (sc.ioException() != null) {
  throw sc.ioException();
  }
  }       
  catch (IOException ex) {
  Logger.getLogger(TestPrintingAllLine.class.getName()).log(Level.SEVERE, null, ex);
  } finally {
  if (inputStream != null) {
  inputStream.close();
  }
  if (sc != null) {
  sc.close();
  }
  }
  </code></pre>
  
  <p>After executing 536 lines then,
  it caused -></p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
    at
    enterdatatosql.TestPrintingAllLine.main(TestPrintingAllLine.java:45)
    Java Result: 1.</p>
    
    <p>45th line is->   System.out.println(data[0]+" "+data[1]+" "+data[2]+"
    "+data[3]);</p>
  </blockquote>