title: OpenCsv writes wrong column names with BeanToCsv + HeaderColumnNameTranslateMappingStrategy
body: <p>I'm using <code>opencsv 3.6</code> in order to create a csv file starting from a java bean.</p>
  
  <p>First of all, I tried this code:</p>
  
  <pre><code>import com.opencsv.CSVReader;
  import com.opencsv.CSVWriter;
  import com.opencsv.bean.BeanToCsv;
  import com.opencsv.bean.HeaderColumnNameTranslateMappingStrategy;
  
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Map;
  
  public class CustomBean {
  
      private String name;
      private String surname;
  
      public CustomBean(String n, String s) {
          this.name = n;
          this.surname = s;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getName() {
          return name;
      }
  
      public void setSurname(String surname) {
          this.surname = surname;
      }
  
      public String getSurname() {
          return surname;
      }
  
      public static void main(String[] args) {
          Map&lt;String,String&gt; mapping = new HashMap&lt;String,String&gt;();
          mapping.put("COLUMN1","name");
          mapping.put("COLUMN2","surname");
  
          HeaderColumnNameTranslateMappingStrategy&lt;CustomBean&gt; strategy = new HeaderColumnNameTranslateMappingStrategy&lt;CustomBean&gt;();
          strategy.setType(CustomBean.class);
          strategy.setColumnMapping(mapping);
  
          ArrayList&lt;CustomBean&gt; customUsers = new ArrayList&lt;CustomBean&gt;();
          customUsers.add(new CustomBean("Kobe","Bryant"));
  
          BeanToCsv&lt;CustomBean&gt; bean = new BeanToCsv&lt;CustomBean&gt;();
  
          try {            
              CSVWriter writer = new CSVWriter(new FileWriter("testOut.csv"));
              bean.write(strategy, writer, customUsers);
              writer.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>But I had the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.RuntimeException: Error writing CSV !
      at com.opencsv.bean.BeanToCsv.write(BeanToCsv.java:74)
      at test.CustomBean.main(CustomBean.java:63)
  Caused by: java.lang.NullPointerException
      at com.opencsv.bean.HeaderColumnNameTranslateMappingStrategy.getColumnName(HeaderColumnNameTranslateMappingStrategy.java:45)
      at com.opencsv.bean.HeaderColumnNameMappingStrategy.findDescriptor(HeaderColumnNameMappingStrategy.java:112)
      at com.opencsv.bean.BeanToCsv.processHeader(BeanToCsv.java:103)
      at com.opencsv.bean.BeanToCsv.write(BeanToCsv.java:69)
      ... 1 more
  </code></pre>
  
  <p>This happens because in opencsv source code in <code>getColumnName</code> method in the <code>HeaderColumnNameTranslateMappingStrategy</code> class there is the following line:</p>
  
  <pre><code>return col &lt; header.length ? columnMapping.get(header[col].toUpperCase()) : null;
  </code></pre>
  
  <p>Therefore, <code>header</code> is null. This is true, in fact this class is a subclass of <code>HeaderColumnNameMappingStrategy</code> class that contains the <code>header</code> variable (<code>String[]</code> type) that is never initialized.</p>
  
  <p>The only useful method I found in this class is <code>captureHeader</code>, but unfortunately it takes a <code>CSVReader</code> as input.</p>
  
  <p>For this reason I created an empty csv file:</p>
  
  <pre><code>COLUMN1,COLUMN2
  </code></pre>
  
  <p>and I added the following lines at the beginning of the try/catch block:</p>
  
  <pre><code>CSVReader reader = new CSVReader(new FileReader("testIn.csv"));
  strategy.captureHeader(reader);
  </code></pre>
  
  <p>In this way (that I really don't like because I have to create a csv file) I have no exception, but in the result csv file the name of the columns does not follow the mapping strategy:</p>
  
  <pre><code>"name","surname"
  "Kobe","Bryant"
  </code></pre>
  
  <p>Two questions:</p>
  
  <ol>
  <li>How can I have the <em>expected</em> result, i.e. the right column names in the csv file?</li>
  <li>There is a way to not use the <code>CSVReader</code> class?</li>
  </ol>