Here you can find the source of encode(String s)
s
using the UTF-8 character encoding.
Parameter | Description |
---|---|
s | a String |
public static String encode(String s)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**//from ww w. j av a 2s . c om * URL Encodes the given String <code>s</code> using the UTF-8 character encoding. * * @param s a String * @return url encoded string */ public static String encode(String s) { if (s == null) return null; try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { // utf-8 always available } return null; } }