title: Splitting error- IndexOutOfBoundsException
body: <p>I got stuck with an issue, that I can't seem to solve. When splitting I should be able to get <em>id, name, check</em> by setting <em>row[0], row[1], row[2]</em>. Strangely only row[0] (id) seem to work. <em>Name, check</em> gives me an error. Could someone help me further?</p>
  
  <p><strong>Example of data:</strong></p>
  
  <pre><code>id,name,check
  1,john,0
  1,patrick,0
  1,naruto,0
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>    ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
      try {
  
          DataInputStream dis = new DataInputStream(openFileInput(listLocation(listLoc)));
          BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String line;
          while ((line = br.readLine()) != null) {
               String[] row = line.split(Pattern.quote(","));
                   //names.add(row[0]); // id
                   names.add(row[1]); // name // ERROR AT THIS LINE
                   //names.add(row[2]); // check
          }
          br.close();
      }
      catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p><strong>Error message:</strong></p>
  
  <pre><code>Caused by: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
  </code></pre>
  
  <p><strong>Solved</strong>
  It seems I had an incorrect value (question marks) at end of file. When removing this line.  My code worked (without Patter.quote). Thank you all for fast reply's. First answer helped me on reminding me of using Log value where I could see the 'incorrect value'. My bad.</p>