title: Getting an ArrayIndexOutOfBoundsException when reading from CSV with JAVA testNG, but why?
body: <p>When using a dataprovider to read a csv with testcases, I'm getting an ArrayIndexOutOfBoundsException.</p>
  
  <p>The CSV looks like this:</p>
  
  <pre><code>TC1;tester@test.com;tester;t;Valid login
  TC2;tester@test.com;incorrect;f;Invalid password
  TC3;incorrect@test.com;tester;f;Invalid user
  TC4;tester@test.com;;fp;Empty password
  TC5;;tester;fe;Empty user
  </code></pre>
  
  <p>The Code:</p>
  
  <pre><code>package tools;
  
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.List;
  
  import org.testng.annotations.DataProvider;
  
  import au.com.bytecode.opencsv.CSVReader;
  
  public class DataProviders {
  
      @DataProvider
      static Object[][] LoginTestInput() throws IOException{
  
          CSVReader reader = new CSVReader(new FileReader("src/input/LoginTestInputFile.csv"));
          List&lt;String[]&gt; myEntries = reader.readAll();
  
          Object[][] returnObject = new Object[myEntries.size()][5];
          for(int i = 1;i&lt;myEntries.size();i++){
              String testCase = myEntries.get(i)[0];
              String username = myEntries.get(i)[1];
              String password = myEntries.get(i)[2];
              String loginSuccessful = myEntries.get(i)[3];
              String description = myEntries.get(i)[4];
              returnObject[i][0] = testCase;
              returnObject[i][1] = username;
              returnObject[i][2] = password;
              returnObject[i][3] = loginSuccessful;
              returnObject[i][4] = description;
  
          }
  
          return returnObject;
      }
  
  }
  </code></pre>
  
  <p>Stacktrace:</p>
  
  <pre><code>java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
         at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:161)
         at org.testng.internal.Parameters.handleParameters(Parameters.java:429)
         at org.testng.internal.Invoker.handleParameters(Invoker.java:1383)
         at org.testng.internal.Invoker.createParameters(Invoker.java:1075)
         at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1180)
         at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
         at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
         at org.testng.TestRunner.privateRun(TestRunner.java:767)
         at org.testng.TestRunner.run(TestRunner.java:617)
         at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
         at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
         at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
         at org.testng.SuiteRunner.run(SuiteRunner.java:240)
         at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
         at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
         at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
         at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
         at org.testng.TestNG.run(TestNG.java:1057)
         at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
         at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
         at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
  Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
         at tools.DataProviders.LoginTestInput(DataProviders.java:22)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
         at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:135)
     ... 20 more
  </code></pre>
  
  <p>Line 22 in the stacktrace refers to: String testCase = myEntries.get(i)[0];</p>