Java Utililty Methods URL Decode

List of utility methods to do URL Decode

Description

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

Method

StringurlDecode(String scope)
Performs url decoding.
StringBuffer result = new StringBuffer();
for (int i = 0; i < scope.length(); ++i) {
    char c = scope.charAt(i);
    if (c == '+') {
        result.append(' ');
    } else if (c == '%' && i + 2 < scope.length()) {
        int start = i + 1;
        String h = scope.substring(start, start + 2);
...
StringURLDecode(String str)
Decode and return the specified URL-encoded String.
return URLDecode(str, null);
Stringurldecode(String str)
The opposite function of urlencode().
int len = str.length();
StringBuffer newstr = new StringBuffer(len);
for (int i = 0; i < len; i++) {
    if (str.charAt(i) == '+') {
        newstr.append(' ');
    } else if (str.charAt(i) == '%') {
        newstr.append(dd2c(str.charAt(i + 1), str.charAt(i + 2)));
        i += 2;
...
StringurlDecode(String str)
url Decode
str = str.replace('_', '/').replace('-', '+');
return str;
StringurlDecode(String text)
url Decode
StringBuilder b = new StringBuilder();
for (int i = 0; i < text.length(); ++i) {
    char ch = text.charAt(i);
    if (ch == '%' && i + 2 < text.length()) {
        String num = text.substring(i + 1, i + 3);
        try {
            int val = Integer.valueOf(num, 16);
            if (val >= 0x20 && val < 0x7F) {
...
byte[]urlDecodeBytes(String key)
url Decode Bytes
byte[] bs = new byte[key.length() / 2];
for (int i = 0; i < key.length() / 2; i++) {
    bs[i] = (byte) (((int) unHex(key.substring(i * 2, i * 2 + 2))) - 128);
return bs;
StringurlDecodeFilename(char[] input)
This method encodes the URL, removes the spaces and brackets from the URL and replaces the same with "%20" and "%5B" and "%5D" and "%7B" "%7D".
if (input == null) {
    return null;
StringBuffer retu = new StringBuffer(input.length);
for (int i = 0; i < input.length; i++) {
    if (input[i] != '%' || i + 2 >= input.length) {
        retu.append(input[i]);
    } else {
...
voidurlDecodeInplace(StringBuilder input)
url Decode Inplace
urlDecodeInto(input, 0, input.length(), input, true);
StringurlDecoder(String encoded)
url Decoder
StringBuffer decoded = new StringBuffer();
int len = encoded.length();
for (int i = 0; i < len; ++i) {
    if (encoded.charAt(i) == '%' && i + 2 < len) {
        int d1 = Character.digit(encoded.charAt(i + 1), 16);
        int d2 = Character.digit(encoded.charAt(i + 2), 16);
        if (d1 != -1 && d2 != -1)
            decoded.append((char) ((d1 << 4) + d2));
...
StringxmlDecode(String s)
Decodes reserved characters in an xml string
if (s == null)
    return s;
try {
    return URLDecoder.decode(s, "UTF-8");
} catch (UnsupportedEncodingException uee) {
    return s;