Java Map to String mapToString(Map map)

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

Description

map To String

License

Open Source License

Declaration

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

Method Source Code

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

import java.util.Collection;

import java.util.Map;

public class Main {
    public static String mapToString(Map<? extends Object, ? extends Object> map) {
        String mapString = map.toString();
        return mapString.substring(1, mapString.length() - 1);
    }//from  w w  w  .  j  a v  a 2s. co m

    public static <T extends Object> String toString(Collection<T> collection) {
        StringBuilder sb = new StringBuilder();

        if (collection.size() == 0) {
            return "";
        }

        for (T object : collection) {
            sb.append(object.toString());
            sb.append(",");
        }

        return sb.substring(0, sb.length() - 1);
    }

    public static <T extends Object> String toString(Collection<T> collection, String delim) {
        StringBuilder sb = new StringBuilder();

        if (collection.size() == 0) {
            return "";
        }

        for (T object : collection) {
            sb.append(object.toString());
            sb.append(delim);
        }

        return sb.substring(0, sb.length() - 1);
    }
}

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)