public String toFormatedString(Iterable<Entry<T, Integer>> set, String separator) { StringBuilder sb = new StringBuilder(); for (Entry<T, Integer> e : set) { toFormatedString(e.getKey(), e.getValue(), sb, separator); } return sb.toString(); }
public void printTopN(PrintStream out, String separator, int n) { List<T> topKeys = getTopKeys(n); StringBuilder sb = new StringBuilder(); for (T key : topKeys) { toFormatedString(key, get(key), sb, separator); } out.print(sb.toString()); }