Here you can find the source of resultSetCurrentData(ResultSet rs)
public static String resultSetCurrentData(ResultSet rs) throws SQLException
//package com.java2s; /*//w w w. jav a2 s . co m * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { private static final int MAX_WIDTH = 20; public static String resultSetCurrentData(ResultSet rs) throws SQLException { ResultSetMetaData metaData = rs.getMetaData(); StringBuilder column = new StringBuilder(); int columns = metaData.getColumnCount(); StringBuilder sb = new StringBuilder(); for (int i = 1; i <= columns; i++) { column.setLength(0); if (i > 1) { sb.append(" | "); } sb.append(trimOrPad(column.append(rs.getString(i)))); } return sb.toString(); } private static StringBuilder trimOrPad(StringBuilder buffer) { if (buffer.length() > MAX_WIDTH) { buffer.setLength(MAX_WIDTH - 1); buffer.append("~"); } else { for (int i = buffer.length(); i < MAX_WIDTH; i++) { buffer.append(" "); } } return buffer; } }