Java Map to String toString(Map map)

Here you can find the source of toString(Map map)

Description

to String

License

Open Source License

Declaration

public static String toString(Map<?, ?> map) 

Method Source Code


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

import java.util.Iterator;
import java.util.Map;

public class Main {
    public static String toString(Map<?, ?> map) {
        if (map == null) {
            return null;
        }//w w  w . j av a2  s  .com
        @SuppressWarnings("rawtypes")
        Iterator iter = map.entrySet().iterator();
        StringBuffer sb = new StringBuffer();
        while (iter.hasNext()) {
            @SuppressWarnings("rawtypes")
            Map.Entry entry = (Map.Entry) iter.next();
            sb.append("(" + entry.getKey() + "," + entry.getValue() + ")\r\n");
        }
        return sb.toString();
    }
}

Related

  1. toQueryString(Map ps)
  2. toStr(Map msg)
  3. toString(final Map tokens)
  4. toString(Map varnames_to_Terms)
  5. toString(Map attributes)
  6. toString(Map map)
  7. toString(Map map)
  8. toString(Map m)
  9. toString(Map map)