Here you can find the source of resultSetToStringFormat(ResultSet rs, String separator, String quote, boolean column)
public static String resultSetToStringFormat(ResultSet rs, String separator, String quote, boolean column) throws SQLException
//package com.java2s; /*/*from w ww. ja v a 2 s . c o m*/ * codjo.net * * Common Apache License 2.0 */ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static String resultSetToStringFormat(ResultSet rs, String separator, String quote, boolean column) throws SQLException { StringBuilder sb = new StringBuilder(); ResultSetMetaData metadata = rs.getMetaData(); int colmumnCount = metadata.getColumnCount(); if (column) { for (int i = 1; i <= colmumnCount; i++) { sb.append(quote).append(metadata.getColumnName(i)).append(quote); if (i + 1 <= colmumnCount) { sb.append(separator); } } sb.append("\n"); } while (rs.next()) { for (int i = 1; i <= colmumnCount; i++) { sb.append(quote).append(rs.getObject(i)).append(quote); if (i + 1 <= colmumnCount) { sb.append(separator); } } sb.append("\n"); } return sb.toString(); } }