title: How to write an arraylist as a CSV
body: <p>I currently have the arraylist from the resultset and I use openCSV library to print as a CSV.</p>
  
  <pre><code>ArrayList&lt;Integer&gt; arlist=new ArrayList&lt;Integer&gt;();
  for(i=1;i&lt;30;i++){
   for(k=1;k&lt;100;k++){
  
         String sql="select count(id) where day=?"
         PreparedStatement pstmt=conn.prepareStatement(sql);
         pstmt.setInt(1,k);
         ResultSet rs=rs.getInt(1);
         int count=rs.getInt(1); 
         arlist.add(count);
     }
  
  
     CSVWriter writer=new CSVWriter(new FileWriter("/home/user/file"+i+".csv"),',')
     writer.writeNext(arlist.toArray(new String [0]));
     writer.close();
     arlist.clear();
  }
  </code></pre>
  
  <p>But the problem is the CSV is a 1 line CSV with 100 columns.Instead  of this I need a 100 line CSV with 1 column.(size of array list is 100).Any help is Appreciated.</p>