Java Map Join joinMap(Map map)

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

Description

join Map

License

LGPL

Declaration

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

Method Source Code

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

import java.util.Map;

public class Main {
    public static String joinMap(Map<?, ?> map) {
        if (map.isEmpty()) {
            return "";
        }//w w  w . j  av a2s  . c  o m
        StringBuilder stringBuilder = new StringBuilder();
        boolean notFirst = false;
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (notFirst) {
                stringBuilder.append(',');
            }
            stringBuilder.append(entry.getKey().toString()).append(':').append(entry.getValue().toString());
            notFirst = true;
        }
        return stringBuilder.toString();
    }
}

Related

  1. join(Map dst, Map src)
  2. join(Map map, String separator)
  3. joinAll(Map> map, String separator)
  4. joinArgs(Map map, String sep, String split)
  5. joinLookup(Iterable elements, String separator, Map lookup)
  6. joinMapToString(Map map, String sSeparator, String sMidSeparator)
  7. joinMapUnmodifiable(Map first, Map second)
  8. joinMapValue(Map map, char connector)
  9. joinOnDelimiter(Map toJoin, char delimiter)