Java tutorial
//package com.java2s; import java.util.Map; public class Main { public static String urlWithParameters(String url, Map<String, Object> params) { StringBuilder builder = new StringBuilder(); if (params != null) { for (Map.Entry<String, Object> entry : params.entrySet()) { if (builder.length() == 0) { if (url.contains("?")) { builder.append("&"); } else { builder.append("?"); } } else { builder.append("&"); } builder.append(entry.getKey()).append("=").append(entry.getValue()); } } return url + builder.toString(); } }