title: Parse CSV file in java, and delaing with empty values
body: <p>I am parsing a CSV file into my program, spliting the values at the <code>,</code> element, and it's working fine, except for when I have lines that have missing values.</p>
  
  <p>The parser is working like this:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  
  public class CsvReader
  {
      private static final String DELIMITER = ",";
      private final BufferedReader br;
      private final String path;
  
      public CsvReader(final String path) throws IOException
      {
          this.path = path;
          this.br = new BufferedReader(new FileReader(path));
      }
  
      public String[] nextLine() throws IOException
      {
          final String line = br.readLine();
          return (line == null) ? new String[0] : line.split(DELIMITER);
      }
  }
  </code></pre>
  
  <p>The lines of data look like this (one line as an example):</p>
  
  <pre><code>J1024205,5028197000004,1,,00,20150603,,Accessories,Factory Test Article (m),ENG,010,110,5,T1,99,99,,,99,99,99,ZZ,ZZ,,5028197242053,30,35028197242054,6,,,OPZ848,3013607800239,OPZ848,,,,50,,
  </code></pre>
  
  <p>Most of the lines in the file complete with this: <code>50,85028197242127,8640</code></p>
  
  <p>But on some lines, the data is missing, so it ends like this: <code>50,,</code></p>
  
  <p>When the file is being processed, these lines are causing a <code>java.lang.ArrayIndexOutOfBoundsException</code>.</p>
  
  <p>How can I best deal with this, if I know that the numbers of objects in the file will remain constant?</p>
  
  <p>I've been told that I need to replace empty values with a null value.</p>