Java Map to String mapToString(Map map)

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

Description

map To String

License

Apache License

Declaration

public static String mapToString(Map map) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static String mapToString(Map map) {
        if (map == null)
            return "null";
        if (map.size() == 0)
            return "empty";

        StringBuilder sb = new StringBuilder();
        sb.append("{");
        for (Object o : map.entrySet()) {
            Map.Entry me = (Entry) o;
            sb.append(me.getKey()).append(": ").append(me.getValue()).append(",");
        }/*from  w ww  .j  a  v  a  2 s.c o m*/
        sb.append("}");
        return sb.toString();
    }
}

Related

  1. mapToString(final Map m)
  2. mapToString(final Map m)
  3. mapToString(final Map map)
  4. mapToString(Map map)
  5. mapToString(Map map)
  6. mapToString(Map map)
  7. mapToString(Map map)
  8. mapToString(Map map)
  9. mapToString(Map map)