Here you can find the source of getMaxColumnSizes(List
Parameter | Description |
---|---|
resultSet | the result set to process |
private static List<Integer> getMaxColumnSizes(List<String[]> resultSet)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w .j av a2 s. c o m*/ * Gets a list of the maximum size for each column. * * @param resultSet the result set to process * @return a list of the maximum size for each column */ private static List<Integer> getMaxColumnSizes(List<String[]> resultSet) { List<Integer> maxColumnSizes = new ArrayList<Integer>(); for (int i = 0; i < resultSet.get(0).length; i++) { int maxColumnSize = -1; for (int j = 0; j < resultSet.size(); j++) { if (resultSet.get(j)[i].length() > maxColumnSize) { maxColumnSize = resultSet.get(j)[i].length(); } } maxColumnSizes.add(maxColumnSize); } return maxColumnSizes; } }