Java Map to String mapToString(Map map)

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

Description

map To String

License

LGPL

Declaration

public static String mapToString(Map<? extends Object, ? extends Object> map) 

Method Source Code

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

import java.util.*;

public class Main {
    public static String mapToString(Map<? extends Object, ? extends Object> map) {
        if (map == null)
            return "null";
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<? extends Object, ? extends Object> entry : map.entrySet()) {
            Object key = entry.getKey();
            Object val = entry.getValue();
            sb.append(key).append("=");
            if (val == null)
                sb.append("null");
            else/*w  w w . j a v a2 s.com*/
                sb.append(val);
            sb.append("\n");
        }
        return sb.toString();
    }
}

Related

  1. mapToString(Map map)
  2. mapToString(Map map)
  3. mapToString(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)