Are there any possible speed improvements I can make to the following method. It takes a JDBC ResultSet and breaks it into several CSV files:
public static void convertToCSV(final ResultSet rs) throws SQLException, IOException {
final DateFormat format = new SimpleDateFormat("yyyyMMdd,HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
final StringBuilder sb = new StringBuilder();
while (rs.next()) {
final File file = new File(sb.append(rs.getString("FIELD1")).append(".csv").toString());
if (!file.exists()) {
file.createNewFile();
}
final BufferedWriter fw = new BufferedWriter(new FileWriter(file.getAbsoluteFile(), true));
fw.write(rs.getString("FIELD2"));
fw.write(',');
fw.write(rs.getString("FIELD3"));
fw.write(',');
final String clobValue = rs.getString("FIELD4");
if(clobValue==null)
fw.write("null,");
else{
fw.write('\"');
fw.write(clobValue);
fw.write("\",");
}
final Date date = new Date(rs.getLong("FIELD5"));
fw.write(format.format(date));
fw.write('\n');
fw.close();
sb.setLength(0);
}
rs.close();
}
Etc/UTC
over justUTC
? \$\endgroup\$Etc
though because I think with Java that means a nautical time zone, which is the opposite of what you would think. \$\endgroup\$