Example usage for org.apache.http.client.utils URLEncodedUtils format

List of usage examples for org.apache.http.client.utils URLEncodedUtils format

Introduction

In this page you can find the example usage for org.apache.http.client.utils URLEncodedUtils format.

Prototype

public static String format(final Iterable<? extends NameValuePair> parameters, final char parameterSeparator,
        final Charset charset) 

Source Link

Document

Returns a String that is suitable for use as an application/x-www-form-urlencoded list of parameters in an HTTP PUT or HTTP POST.

Usage

From source file:org.matonto.rest.util.LinksUtils.java

private static String buildQueryString(MultivaluedMap<String, String> queryParams, int start) {
    List<NameValuePair> params = new ArrayList<>();

    queryParams.forEach((key, values) -> {
        if (key.equals("offset")) {
            params.add(new BasicNameValuePair(key, String.valueOf(start)));
        } else {//from w w  w. j  av  a  2  s.  c om
            params.add(new BasicNameValuePair(key, values.get(0)));
        }
    });

    return URLEncodedUtils.format(params, '&', Charset.forName("UTF-8"));
}