Here you can find the source of join(HashMap
public static String join(HashMap<String, String> params, String separator)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/* www .j a va 2 s .co m*/ * Joins list of string items to a single string, where items are separated * with a defined separator. * * @param list to join into string * @param separator to be used between elements * @return items joined into a single string */ public static String join(List<?> list, String separator) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } String output = ""; if (list != null && list.size() > 0) { for (int i = 1; i <= list.size(); i++) { output = output + list.get(i - 1); if (i < list.size()) { output = output + separator; } } } return output; } /** * Joins list of string items to a single string, where items are separated * with a defined separator. * * @param args to join into string * @param separator to be used between elements * @return items joined into a single string */ public static String join(Object[] args, String separator) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } if (args != null && args.length > 0) { List<Object> array = Arrays.asList(args); return join(array, separator); } return ""; } /** * Joins list of string items to a single string, where items are separated * with a defined separator. * * @param items to join into string * @param separator to be used between elements * @return items joined into a single string */ public static String join(Set<String> items, String separator) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } if (items != null && items.size() > 0) { Object[] array = items.toArray(); return join(array, separator); } return ""; } public static String join(HashMap<String, String> params, String separator) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } String output = ""; if (params != null) { for (String name : params.keySet()) { if (output.length() > 0) { output = output + separator; } output = output + name + "=" + params.get(name); } } return output; } }