title: Java - Write hashmap to a csv file
body: <p>I have a hashmap with a String key and String value. It contains a large number of keys and their respective values.</p>
  <p>For example:</p>
  <pre><code>key | value
  abc | aabbcc
  def | ddeeff
  </code></pre>
  <p>I would like to write this hashmap to a csv file such that my csv file contains rows as below:</p>
  <pre><code>abc,aabbcc
  def,ddeeff
  </code></pre>
  <p>I tried the following example here using the supercsv library: <a href="http://javafascination.blogspot.com/2009/07/csv-write-using-java.html" rel="nofollow noreferrer">http://javafascination.blogspot.com/2009/07/csv-write-using-java.html</a>. However, in this example, you have to create a hashmap for each row that you want to add to your csv file. I have a large number of key value pairs which means that several hashmaps, with each containing data for one row need to be created. I would like to know if there is a more optimized approach that can be used for this use case.</p>