@@ -0,0 +1,776 @@
+package jp.co.flect.csv;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.sql.ResultSet;%0Aimport java.sql.ResultSetMetaData;%0Aimport java.sql.SQLException;%0Aimport java.util.Arrays;%0A%0Apublic class CSVUtils %7B%0A%09%0A%09public static void resultSetToCsv(ResultSet rs, File f) throws IOException, SQLException %7B%0A%09%09CSVWriter writer = new CSVWriter(f);%0A%09%09try %7B%0A%09%09%09ResultSetMetaData meta = rs.getMetaData();%0A%09%09%09String%5B%5D lines = new String%5Bmeta.getColumnCount()%5D;%0A%09%09%09for (int i=0; i%3Clines.length; i++) %7B%0A%09%09%09%09lines%5Bi%5D = meta.getColumnLabel(i+1);%0A%09%09%09%7D%0A%09%09%09writer.write(lines);%0A%09%09%09while (rs.next()) %7B%0A%09%09%09%09Arrays.fill(lines, null);%0A%09%09%09%09for (int i=0; i%3Clines.length; i++) %7B%0A%09%09%09%09%09lines%5Bi%5D = rs.getString(i+1);%0A%09%09%09%09%7D%0A%09%09%09%09writer.write(lines);%0A%09%09%09%7D%0A%09%09%7D finally %7B%0A%09%09%09writer.close();%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add CSVUtils#resultSetToCsv