Here you can find the source of dumpMap(PrintStream out, Map Values)
Parameter | Description |
---|---|
out | non-null printstream |
Values | non-null Map |
public static void dumpMap(PrintStream out, Map Values)
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.*; public class Main { /**//www.j a v a 2 s. c o m * print a string listing what is in a Map * Works best of all entried are string or have * good toString methods * @param out non-null printstream * @param Values non-null Map */ public static void dumpMap(PrintStream out, Map Values) { out.println(describeMap(Values)); } /** * Wrapper for System.out.println so I can track * where output is coming from * @param s non-null string to print */ public static void println(Object s) { println(s.toString()); } /** * Wrapper for System.out.println so I can track * where output is coming from * @param s non-null string to print */ public static void println(String s) { System.out.println(s); } /** * build a strig listing what is in a Map * Works best of all entried are string or have * good toString methods * @param Values non-null Map * @return non-nul string */ public static String describeMap(Map Values) { SortedSet keys = new TreeSet(Values.keySet()); Iterator it = keys.iterator(); StringBuffer sb = new StringBuffer(); int lineLength = 0; while (it.hasNext()) { Object key = it.next(); String keyStr = key.toString(); String value = Values.get(key).toString(); if (value.length() == 0) value = "\'\'"; sb.append("key = "); sb.append(keyStr); sb.append(" value = "); sb.append(value); lineLength += 14 + keyStr.length() + value.length(); if (lineLength > 80) { lineLength = 0; sb.append("\n"); } else { sb.append(" "); } } return (sb.toString()); } /**{ method @name toString @function convert a char to a string @param c the char @return the String }*/ public static String toString(char c) { StringBuffer s = new StringBuffer(); s.append(c); return (s.toString()); } }