Here you can find the source of printHeaders(ResultSetMetaData rsmd, PrintStream out)
private static void printHeaders(ResultSetMetaData rsmd, PrintStream out) throws SQLException
//package com.java2s; //License from project: Open Source License import java.io.PrintStream; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { private static void printHeaders(ResultSetMetaData rsmd, PrintStream out) throws SQLException { StringBuilder sb = new StringBuilder(); sb.append("| "); for (int i = 1; i <= rsmd.getColumnCount(); i++) { sb.append(rsmd.getColumnLabel(i)).append(" | "); }//from ww w. j av a 2s .co m sb.append('\n'); for (int i = 0; i < sb.length(); i++) out.print('-'); out.print('\n'); out.print(sb.toString()); for (int i = 0; i < sb.length(); i++) out.print('-'); out.print('\n'); } }