Here you can find the source of encode(Object parameter)
Parameter | Description |
---|---|
parameter | The query parameter to encode. This object will not be changed. |
public static String encode(Object parameter)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**/* ww w . j av a2 s . c o m*/ * URL encode a single query parameter. * @param parameter The query parameter to encode. This object will not be * changed. * @return The URL encoded string representation of the parameter. If the * parameter is null, returns null. */ public static String encode(Object parameter) { if (parameter == null) { return null; } try { return URLEncoder.encode(parameter.toString(), "UTF-8"); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } }