title: Java: print csv on different columns?
body: <p>I want to print the query table results on a CSV file. </p>
  
  <p>I tried using this code:</p>
  
  <pre><code>PrintWriter csvWriter = new PrintWriter(new File(path + "SqlClient_" + date + ".csv")) ;
  ResultSetMetaData meta = rs.getMetaData() ; 
  int numberOfColumns = meta.getColumnCount() ; 
  String dataHeaders = "\"" + meta.getColumnName(1) + "\"" ; 
  for (int i = 2 ; i &lt; numberOfColumns + 1 ; i ++ ) { 
         dataHeaders += ",\"" + meta.getColumnName(i) + "\"" ;
      }
      csvWriter.println(dataHeaders) ;
      while (rs.next()) {
          String row = "\"" + rs.getString(1) + "\""  ; 
          for (int i = 2 ; i &lt; numberOfColumns + 1 ; i ++ ) {
               row += ",\"" + rs.getString(i) + "\"" ;
          }
          csvWriter.println(row) ;
      }
      csvWriter.close();
  </code></pre>
  
  <p>This is what i obtain:</p>
  
  <pre><code>title1","title2","title3"
  "date1","date2","date3"
  ....
  </code></pre>
  
  <p>This is write inside a single column, instead i want to write on different column, something like:</p>
  
  <pre><code>title1 | title2 | title3 
  data1| data2 | data3 |
  </code></pre>
  
  <p>There is a special command to split the string into different columns?</p>