Java String Encode encodeParams(String encoding, String... params)

Here you can find the source of encodeParams(String encoding, String... params)

Description

Encodes the list of path parts that will be separated by /.

License

Open Source License

Parameter

Parameter Description
encoding Encoding.
params Parameters to be encoded.

Exception

Parameter Description
UnsupportedEncodingException If the encoding is not supported.

Return

The encoded array of parameters.

Declaration

public static List<String> encodeParams(String encoding, String... params) throws UnsupportedEncodingException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import java.util.Arrays;
import java.util.List;

public class Main {
    /**//from  ww  w  .  java2s  .  c  om
     * Encodes the list of path parts that will be separated by /.
     * 
     * @param encoding
     *            Encoding.
     * @param params
     *            Parameters to be encoded.
     * @return The encoded array of parameters.
     * @throws UnsupportedEncodingException
     *             If the encoding is not supported.
     */
    public static List<String> encodeParams(String encoding, String... params) throws UnsupportedEncodingException {
        List<String> encodedParams = Arrays.asList(params);

        for (int i = 0; i < encodedParams.size(); ++i) {
            encodedParams.set(i, URLEncoder.encode(params[i], encoding));
        }

        return encodedParams;
    }
}

Related

  1. encodeParameters(Map> parameters)
  2. encodeParameters(Map parameters)
  3. encodeParameters(Map params, String paramsEncoding)
  4. encodeParams(final Map params)
  5. encodeParams(Map nameValuePairs)
  6. EncodePath(String path)
  7. encodePath(String path)
  8. encodePath(String str)
  9. encodeRfc5849(final String value)