Java Utililty Methods List Print

List of utility methods to do List Print

Description

The list of methods to do List Print are organized into topic(s).

Method

voidprintPerformanceStats(String message, List iterationTimesInNanoseconds)
print Performance Stats
Long max = Collections.max(iterationTimesInNanoseconds);
Long min = Collections.min(iterationTimesInNanoseconds);
System.out.format("%s: totalIterations=%d, min=%d us, max=%d us, avg=%d us.\n", message,
        iterationTimesInNanoseconds.size(), min / 1000, max / 1000,
        average(iterationTimesInNanoseconds) / 1000);
voidprintQueryResults(List res)
Convenience method for printing query results.
if (res == null || res.isEmpty())
    System.out.println("Query result set is empty.");
else {
    for (Object row : res) {
        if (row instanceof List) {
            System.out.print("(");
            List<?> l = (List) row;
            for (int i = 0; i < l.size(); i++) {
...
voidprintRules(List rules, Class clazz)
print Rules
System.out.println("[" + clazz.getName() + "] applied rules: ");
for (String rule : rules) {
    System.out.println(rule);
voidprintStats(final List shocktimes)
print Stats
System.out.println("N: " + shocktimes.size());
long sum = 0;
for (final Long l : shocktimes) {
    sum += l;
final double mean = (sum / (double) shocktimes.size()) / 1000000000.0;
System.out.println("Mean: " + mean);
double ss = 0;
...
voidprintStringList(List list, String name)
print String List
String output = "";
for (String text : list) {
    output += " '" + text + "' ";
System.out.println("###########" + name + "########## " + output);
StringprintStringList(List listToPrint)
Prints the elements of a string list without leading and ending brackets.
return listToPrint.toString().replace("[", "").replace("]", "").trim();
voidprintStringList(List strings)
Prints a list of String to System.out.

Iterator<String> i = strings.iterator();
System.out.println("\nSize: " + strings.size() + "\n");
while (i.hasNext()) {
    System.out.println(i.next());
System.out.println("\n--------------------------------");
voidprintTable(List data)
print the table
if (isNotProperTableData(data)) {
    return;
int numColumns = data.get(0).split("\\s").length;
int size = 0;
for (int i = 0; i < numColumns; i++) {
    size += getColumnSize(data, i);
int adjustedSize = size + 6 + (numColumns - 1) * 3; 
System.out.println(doubleHorizontalLine(adjustedSize));
for (int i = 0; i < data.size(); i++) {
    String line = data.get(i);
    System.out.print("||");
    String[] columnData = line.split("\\s");
    for (int j = 0; j < numColumns; j++) {
        System.out.print(" " + columnData[j] + getCellSpaces(data, j, columnData[j]) + " |");
    System.out.println("|");
System.out.println(doubleHorizontalLine(adjustedSize));
voidprintTopNTokens(LinkedList> list, int n)
This function takes a sorted List as input and print top N elements
Iterator<Entry<String, Integer>> iterator = list.descendingIterator();
int size = list.size() - 1;
if (size < 0) {
    System.out.println("Empty Set");
    return;
System.out.format("\n%-20s%20s\n", "Token", "Frequency");
System.out.println("---------------------------------------------------------------------------------");
...
voidprintTuple(List tuple)
Print one tuple to stdout.
System.out.println("Tuple:");
int i = 0;
for (Object v : tuple) {
    if (v instanceof String)
        System.out.println("  Value[" + i + "]: " + (String) v);
    else if (v instanceof Integer)
        System.out.println("  Value[" + i + "]: " + v);
    i++;
...