Here you can find the source of join(Map
public static List<String> join(Map<String, String> map, String separator)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static List<String> join(Map<String, String> map, String separator) { if (map == null) { return null; }//from w w w . j av a 2s . c o m List<String> list = new ArrayList<String>(); if (map == null || map.size() == 0) { return list; } for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (value == null || value.length() == 0) { list.add(key); } else { list.add(key + separator + value); } } return list; } public static String join(List<String> list, String separator) { StringBuilder sb = new StringBuilder(); for (String ele : list) { if (sb.length() > 0) { sb.append(separator); } sb.append(ele); } return sb.toString(); } }