Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Map; import java.util.Set; public class Main { static public String assemblyUrlByCommon(String url, Map<String, String> params) { if (params == null && params.size() == 0) { return url; } else { StringBuilder sb = new StringBuilder(url); sb.append("?"); Set<String> keys = params.keySet(); int i = 0; for (String key : keys) { String value = params.get(key); sb.append(key).append("=").append(value); if (i != keys.size() - 1) { sb.append("&"); } i++; } return sb.toString(); } } }