Java URI Decode decodeURI(String s)

Here you can find the source of decodeURI(String s)

Description

Decodes the passed UTF-8 String using an algorithm that's compatible with JavaScript's decodeURIComponent function.

License

LGPL

Parameter

Parameter Description
s The UTF-8 encoded String to be decoded

Return

the decoded String

Declaration

public static String decodeURI(String s) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.net.URLDecoder;

public class Main {
    /**/*from  ww  w  .j  ava2s .  c  o m*/
     * Decodes the passed UTF-8 String using an algorithm that's compatible with
     * JavaScript's
     * <code>decodeURIComponent</code> function. Returns
     * <code>null</code> if the String is
     * <code>null</code>.
     *
     * @param s The UTF-8 encoded String to be decoded
     * @return the decoded String
     */
    public static String decodeURI(String s) {
        if (s == null) {
            return null;
        }
        String result;
        try {
            result = URLDecoder.decode(s, "UTF-8");
        } // This exception should never occur.
        catch (Exception e) {
            result = s;
        }
        return result;
    }
}

Related

  1. decode(String uri)
  2. decodeToUtf8(String uri)
  3. decodeUnreserved(URI address)
  4. decodeURI(CharSequence uriCharSequence, String charset)
  5. decodeURI(java.net.URI uri)
  6. decodeURI(String str, boolean fullUri)
  7. decodeUri(String string)
  8. decodeURI(String uri)
  9. decodeURI(URI uri)