Here you can find the source of encode(String s)
Parameter | Description |
---|---|
s | a string to be URL-encoded |
public static final String encode(String s)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**//from w w w .j av a2 s . c o m * URL encoding. * @param s a string to be URL-encoded * @return URL encoding of s using character encoding UTF-8; null if s is null. */ public static final String encode(String s) { try { if (s != null) return URLEncoder.encode(s, "UTF-8"); else return s; } catch (UnsupportedEncodingException e) { // Java Spec requires UTF-8 be in all Java environments, so this should not happen return s; } } }