Java Map Join joinArgs(Map map, String sep, String split)

Here you can find the source of joinArgs(Map map, String sep, String split)

Description

join Args

License

Open Source License

Declaration

public static final String joinArgs(Map<String, String> map, String sep, String split) 

Method Source Code

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

import java.util.Map;

public class Main {
    public static final String joinArgs(Map<String, String> map, String sep, String split) {
        StringBuilder sb = new StringBuilder();

        for (String key : map.keySet()) {
            sb.append(key);//from  w w  w . j a  v a2s  . c om
            sb.append(split);
            sb.append(map.get(key));
            sb.append(sep);
        }

        if (sb.length() > 0) {
            sb.setLength(sb.length() - 1);
        }

        return sb.toString();
    }

    public static final String joinArgs(Map<String, String> map, char sep, char split) {
        StringBuilder sb = new StringBuilder();

        for (String key : map.keySet()) {
            sb.append(key);
            sb.append(split);
            sb.append(map.get(key));
            sb.append(sep);
        }

        if (sb.length() > 0) {
            sb.setLength(sb.length() - 1);
        }

        return sb.toString();
    }
}

Related

  1. join(List> list)
  2. Join(Map map, String entryGlue, String elementGlue)
  3. join(Map dst, Map src)
  4. join(Map map, String separator)
  5. joinAll(Map> map, String separator)
  6. joinLookup(Iterable elements, String separator, Map lookup)
  7. joinMap(Map map)
  8. joinMapToString(Map map, String sSeparator, String sMidSeparator)
  9. joinMapUnmodifiable(Map first, Map second)