need to write 2.5 million data into csv from resultset, what is the best approach to write these huge data in java : <p>Need to write  2.5 million data into csv from resultset, what is the best approach to write these huge data in java.Currently its taking 1.5 hours to write.
Sample Code:</p>

<pre><code>PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("test.csv"), "UTF-8")), false);

int colcount= rs.getMetaData().getColumnCount();

while(rs.next()){
  // working on some headers
   for (int i= 1; i&lt;= colcount; i++) {
        Object value = rs.getObject(i);
        pw.println(value.toString());
   }
}
</code></pre>

<p>please help me</p>
