title: Reading CSV file in Java with headers and multiple columns
body: <p>I am reading a CSV file that looks like the following:</p>
  
  <pre><code>    Red Blue Green
  1st   Y    N     
  2nd   Y    Y     N
  3rd   N          Y
  </code></pre>
  
  <p>I want the output to be something like </p>
  
  <p>1st Red Y <br>
  1st Blue N <br>
  2nd Red Y <br>
  2nd Blue Y <br>
  2nd Green N <br> 
  3rd Red N <BR>
  3rd Green Y <BR></p>
  
  <p>I am pulling in the colors row into an array, but I am not sure how to get my desired output.  Below is my code so far:</p>
  
  <pre><code>public String readFile(File aFile) throws IOException {
      StringBuilder contents = new StringBuilder();
      ArrayList&lt;String&gt; topRow = new ArrayList&lt;String&gt;();
  
      try {
          BufferedReader input =  new BufferedReader(new FileReader(aFile));
  
          try {
              String line = null; 
  
          while (( line = input.readLine()) != null){
             if(line.startsWith(",")) {
                for (String retval: line.split(",")) {
                   topRow.add(retval);
                   //System.out.println(retval);
  
                }
             }
          }
        }
        finally {
          input.close();
        }
      }
      catch (IOException ex){
        ex.printStackTrace();
      }
  
      return contents.toString(); 
  }
  </code></pre>