Java Utililty Methods URL Encode

List of utility methods to do URL Encode

Description

The list of methods to do URL Encode are organized into topic(s).

Method

Stringencode(byte[] bytes, String encoding)
Encode a byte string as a String.
if (bytes == null) {
    return null;
} else if (encoding == null) {
    return urlEncode(bytes);
} else if ("url".equals(encoding)) {
    return urlEncode(bytes);
} else if ("hex".equals(encoding)) {
    return toHex(bytes);
...
Stringencode(final Object id)
encode
if (id instanceof String)
    return URLEncoder.encode(id.toString());
else
    return id.toString();
Stringencode(final String content, final String encoding)
encode
try {
    return URLEncoder.encode(content, encoding != null ? encoding : "UTF-8");
} catch (UnsupportedEncodingException problem) {
    throw new IllegalArgumentException(problem);
Stringencode(final String raw)
Encodes the given raw text using the UTF-8 URL encoding scheme.
try {
    return URLEncoder.encode(raw, "UTF-8");
} catch (final UnsupportedEncodingException e) {
    return raw; 
Stringencode(final String s, final String enc)
<#if locale="en">

Encode string with the encode character.

try {
    return URLEncoder.encode(s, enc);
} catch (final UnsupportedEncodingException e) {
    throw new RuntimeException(e);
Stringencode(final String string)
URL encodes the specified string using the ISO-8859-1 encoding if applicable, otherwise the system default encoding will be used.
return encode(string, null);
Stringencode(final String value, final String charset)
encode
try {
    return URLEncoder.encode(value, charset);
} catch (UnsupportedEncodingException e) {
    throw new IllegalStateException(e);
Stringencode(HashMap map)
encode
if (map == null) {
    return null;
StringBuilder str = new StringBuilder();
Set<String> keys = map.keySet();
boolean first = true;
for (String key : keys) {
    Object value = map.get(key);
...
Stringencode(Object parameter)
URL encode a single query parameter.
if (parameter == null) {
    return null;
try {
    return URLEncoder.encode(parameter.toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
Stringencode(Object value)
encode
if (value == null)
    return "";
try {
    return URLEncoder.encode(value.toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
    return value.toString();