Here you can find the source of addParams(final Map
public static void addParams(final Map<String, String> params, final StringBuilder uri)
//package com.java2s; /****************************************************************************** * Copyright (c) 2011 GitHub Inc.// w ww . j a v a 2s .c om * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Kevin Sawicki (GitHub Inc.) - initial API and implementation *****************************************************************************/ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; public class Main { public static void addParams(final Map<String, String> params, final StringBuilder uri) { if (params == null || params.isEmpty()) return; for (Map.Entry<String, String> param : params.entrySet()) addParam(param.getKey(), param.getValue(), uri); } public static void addParam(final String name, final String value, final StringBuilder uri) { if (uri.length() > 0) uri.append('&'); uri.append(encode(name)).append('='); if (value != null) uri.append(encode(value)); } public static String encode(final String value) { try { return URLEncoder.encode(value, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } } }