java.lang.Object
org.seppiko.commons.utils.codec.URLCodecUtil
URL Encoding and Decoding util
- Author:
- Leonard Woo
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDecodes an application/x-www-form-urlencoded string using default charset.static StringDecodes an application/x-www-form-urlencoded string using a specific encoding scheme.static StringDecodes an application/x-www-form-urlencoded string using a specificCharset.static StringTranslates a string into application/x-www-form-urlencoded format using default charset.static StringTranslates a string into application/x-www-form-urlencoded format using a specific encoding scheme.static StringTranslates a string into application/x-www-form-urlencoded format using a specificCharset.static StringThe default charset used for string decoding and encoding.
-
Method Details
-
getDefaultCharset
The default charset used for string decoding and encoding.- Returns:
- the default string charset name
-
encode
Translates a string into application/x-www-form-urlencoded format using default charset.- Parameters:
str- String to be translated- Returns:
- the translated String
- Throws:
NullPointerException- if str is null
-
encode
public static String encode(String str, String charsetName) throws UnsupportedEncodingException, NullPointerException Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.- Parameters:
str- String to be translatedcharsetName- the given charset name- Returns:
- the translated String
- Throws:
UnsupportedEncodingException- if this charset is unsupportedNullPointerException- if str or charsetName is null
-
encode
Translates a string into application/x-www-form-urlencoded format using a specificCharset.- Parameters:
str- String to be translatedcharset- the given charset- Returns:
- the translated String
- Throws:
NullPointerException- if str or charset is null
-
decode
Decodes an application/x-www-form-urlencoded string using default charset.- Parameters:
str- the String to decode- Returns:
- the newly decoded string
- Throws:
UnsupportedEncodingException- can not decode with default charsetNullPointerException- if str is null
-
decode
public static String decode(String str, String charsetName) throws UnsupportedEncodingException, NullPointerException Decodes an application/x-www-form-urlencoded string using a specific encoding scheme.- Parameters:
str- the String to decodecharsetName- the given charset name- Returns:
- the newly decoded string
- Throws:
UnsupportedEncodingException- if this charset could not decode or unsupported charsetNullPointerException- if str or charsetName is null
-
decode
public static String decode(String str, Charset charset) throws UnsupportedEncodingException, NullPointerException Decodes an application/x-www-form-urlencoded string using a specificCharset.- Parameters:
str- the String to decodecharset- the given charset- Returns:
- the newly decoded string
- Throws:
UnsupportedEncodingException- if this charset could not decodeNullPointerException- if str or charset is null
-