public class URLEncoder extends Object
application/x-www-form-urlencoded MIME content type.
All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') and characters '.', '-', '*', '_' are converted into their hexadecimal value prepended by '%'. For example: '#' -> %23. In addition, spaces are substituted by '+'.
| Modifier and Type | Method and Description |
|---|---|
static String |
encode(String s)
Deprecated.
Use
encode(String, String) instead. |
static String |
encode(String s,
Charset charset)
Translates a string into
application/x-www-form-urlencoded
format using a specific Charset. |
static String |
encode(String s,
String charsetName)
|
@Deprecated public static String encode(String s)
encode(String, String) instead.encode(s, "UTF-8").public static String encode(String s, String charsetName) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic static String encode(String s, Charset charset)
application/x-www-form-urlencoded
format using a specific Charset.
This method uses the supplied charset to obtain the bytes for unsafe
characters.
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
s - String to be translated.charset - the given charsetString.NullPointerException - if s or charset is null.URLDecoder.decode(java.lang.String, java.nio.charset.Charset)