Java URL Decode decode(String input)

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

Description

* Returns a URL decoded String obtained from input, which is assumed to be a URL encoded String composed of characters in the default charset.

License

Apache License

Parameter

Parameter Description
input A URL encoded String

Return

A String that has been URL decoded

Declaration

public static String decode(String input) 

Method Source Code

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

import java.net.URLDecoder;

public class Main {
    private static String CHARSET = "UTF-8";

    /** *************************************************************
     * Returns a URL decoded String obtained from input, which is
     * assumed to be a URL encoded String composed of characters in
     * the default charset.  In most cases, the charset will be UTF-8.
     *// w  ww. j av a  2  s.c om
     * @param input A URL encoded String
     *
     * @return A String that has been URL decoded
     */
    public static String decode(String input) {

        String decoded = input;
        try {
            decoded = URLDecoder.decode(input, getCharset());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return decoded;
    }

    /** *************************************************************
     * Returns a String denoting a character encoding scheme.  The
     * default value is "UTF-8".
     *
     * @return String
     */
    public static String getCharset() {
        return CHARSET;
    }
}

Related

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