Java Collection Print println(Collection lines, String suffix, String prefix)

Here you can find the source of println(Collection lines, String suffix, String prefix)

Description

println

License

Open Source License

Declaration

public static void println(Collection<? extends Object> lines, String suffix, String prefix) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

import java.util.List;

public class Main {
    public static void println(Collection<? extends Object> lines, String suffix, String prefix) {
        System.out.println(toString(lines, suffix, prefix));
    }//  w  w w. j  av  a  2  s  . c  om

    public static String toString(Collection<? extends Object> collection, String prefix, String suffix) {
        StringBuilder sb = new StringBuilder();
        for (Object line : collection) {
            sb.append(prefix);
            sb.append(line.toString());
            sb.append(suffix);
        }
        return sb.toString();
    }

    public static String toString(List<List<String>> collection, String betweenElements, String betweenRows) {
        StringBuilder sb = new StringBuilder();
        for (List<String> row : collection) {
            sb.append(row.get(0));
            sb.append(betweenElements);
            sb.append(row.get(1));
            sb.append(betweenRows);
        }
        return sb.toString();
    }
}

Related

  1. printCollectionDebug(Collection c)
  2. printCollectionSorted(Collection l, String indent)
  3. printElement(Collection pCollection, boolean pAllElement)
  4. printElementsUnderCollection(Collection collection)
  5. printList(Collection collection)
  6. printMatrixList( Collection collection)
  7. printObjectArray(Collection valueArrays)