Java List Max getMaxColumnSizes(List resultSet)

Here you can find the source of getMaxColumnSizes(List resultSet)

Description

Gets a list of the maximum size for each column.

License

Open Source License

Parameter

Parameter Description
resultSet the result set to process

Return

a list of the maximum size for each column

Declaration

private static List<Integer> getMaxColumnSizes(List<String[]> resultSet) 

Method Source Code

//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;
    }
}

Related

  1. getMax(List aList)
  2. getMax(List d)
  3. getMax(List list)
  4. getMax(List numbers)
  5. getMax(List list)
  6. getMaxGYS(List values)
  7. getMaxId(List ids)
  8. getMaximums(List data)
  9. getMaxLength(List values)