Here you can find the source of encode(String input)
Parameter | Description |
---|---|
input | A String which has not yet been URL encoded |
public static String encode(String input)
//package com.java2s; //License from project: Apache License import java.net.URLEncoder; public class Main { private static String CHARSET = "UTF-8"; /** ************************************************************* * Returns a URL encoded String obtained from input, which is * assumed to be a String composed of characters in the default * charset. In most cases, the charset will be UTF-8. */*from www . ja v a 2s . co m*/ * @param input A String which has not yet been URL encoded * * @return A URL encoded String */ public static String encode(String input) { String encoded = input; try { encoded = URLEncoder.encode(input, getCharset()); } catch (Exception ex) { ex.printStackTrace(); } return encoded; } /** ************************************************************* * Returns a String denoting a character encoding scheme. The * default value is "UTF-8". * * @return String */ public static String getCharset() { return CHARSET; } }