Java Utililty Methods Map Print

List of utility methods to do Map Print

Description

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

Method

voidprintHash(HashMap hashMap)
print Hash
Set<?> s = hashMap.entrySet();
Iterator<?> it = s.iterator();
while (it.hasNext()) {
    Map.Entry m = (Map.Entry) it.next();
    System.out.println(m.getKey() + "\t" + m.getValue());
voidprintHash(HashMap hashMap)
HashMap Operations
System.out.println("Print HashMap");
Set s = hashMap.entrySet();
Iterator it = s.iterator();
while (it.hasNext()) {
    Map.Entry m = (Map.Entry) it.next();
    System.out.println(m.getKey() + "\t" + m.getValue());
intprintHashMap(String lt, HashMap map, String rt, int maxparm)
print Hash Map
Set<String> keySetOfPaths = map.keySet();
Iterator<String> itrKeySetOfPaths = keySetOfPaths.iterator();
int maxlen = maxparm;
while (itrKeySetOfPaths.hasNext()) {
    String aKey = itrKeySetOfPaths.next();
    if (maxlen < aKey.length())
        maxlen = aKey.length();
keySetOfPaths = map.keySet();
itrKeySetOfPaths = keySetOfPaths.iterator();
while (itrKeySetOfPaths.hasNext()) {
    String aKey = itrKeySetOfPaths.next();
    String aVal = map.get(aKey);
    int gap = maxlen - aKey.length();
    System.out.print(lt + aKey);
    for (int i = 0; i < gap; i++)
        System.out.print(" ");
    System.out.println(" , " + aVal + rt);
return maxlen;
voidprintHeaders(Map> headers)
print Headers
for (Entry<String, List<String>> h : headers.entrySet()) {
    String name = h.getKey();
    for (String value : h.getValue()) {
        if (name != null) {
            System.err.println(name + ":\t" + value);
        } else {
            System.err.println(value);
voidprintHttpMessage(String statusLine, Map headers)
print Http Message
System.out.println(statusLine);
for (String header : headers.keySet()) {
    System.out.println(header + ": " + headers.get(header));
voidprintItems(HashMap map)
Listing of all items in a hashmap (useful for formItems

HashMap map Input to iterate over and print items

for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
    Map.Entry item = (Map.Entry) iter.next();
    Object value = item.getValue();
    if (value instanceof String[]) {
        String[] list = (String[]) value;
        StringBuffer out = new StringBuffer();
        out.append(item.getKey());
        out.append(" - [");
...
voidprintKeys(Map m)
Print the keys in a HashMap.
for (Object s : m.keySet()) {
    System.out.println(s);
voidprintMap(final Map msg)
The Method printMap prints the HashMap to the console.
for (Entry<K, V> entry : msg.entrySet()) {
    final K key = entry.getKey();
    final V value = entry.getValue();
    System.out.println("[" + key.toString() + "=" + value.toString() + "]");
voidprintMap(HashMap map)
print Map
java.util.Iterator iterator = map.keySet().iterator();
Object key = null;
Object obj = null;
while (iterator.hasNext()) {
    key = iterator.next();
    obj = map.get(key);
    System.out.println("key:" + key + " value:" + obj);
voidprintMap(Map map)
print Map
Iterator itr = map.keySet().iterator();
System.out.println("-----Printing Map-----");
while (itr.hasNext()) {
    Object obj = itr.next();
    System.out.println(obj + " : " + map.get(obj));
System.out.println("-----End Of Map-----");