Java URL Decode decode(String s)

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

Description

URL decoding.

License

Apache License

Parameter

Parameter Description
s a URL-encoded string to be URL-decoded

Return

URL decoded value of s using character encoding UTF-8; null if s is null.

Declaration

public static final String decode(String s) 

Method Source Code

//package com.java2s;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class Main {
    /**/*from   w w  w  .  j  a v  a2 s.  co  m*/
     * URL decoding.
     * @param s a URL-encoded string to be URL-decoded
     * @return URL decoded value of s using character encoding UTF-8; null if s is null.
     */
    public static final String decode(String s) {
        try {
            if (s != null)
                return URLDecoder.decode(s, "UTF-8");
            else
                return s;
        } catch (UnsupportedEncodingException e) {
            // Java Spec requires UTF-8 be in all Java environments, so this should not happen
            return s;
        }
    }
}

Related

  1. decode(String input)
  2. decode(String input)
  3. decode(String path)
  4. decode(String path, String encoding)
  5. decode(String raw)
  6. decode(String s)
  7. decode(String s)
  8. decode(String s)
  9. decode(String s)