Java URL Decode decode(String path, String encoding)

Here you can find the source of decode(String path, String encoding)

Description

Decode the path.

License

Open Source License

Parameter

Parameter Description
path the path to decode
encoding the encodeing

Return

decoded path

Declaration

public static String decode(String path, String encoding) 

Method Source Code

//package com.java2s;
/*/*from w w w  .j a v  a 2  s .c  om*/
* JBoss, Home of Professional Open Source
* Copyright 2006, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import java.io.UnsupportedEncodingException;

import java.net.URLDecoder;

public class Main {
    /** The default encoding */
    private static final String DEFAULT_ENCODING = "UTF-8";

    /**
     * Decode the path with UTF-8 encoding..
     *
     * @param path the path to decode
     * @return decoded path
     */
    public static String decode(String path) {
        return decode(path, DEFAULT_ENCODING);
    }

    /**
     * Decode the path.
     *
     * @param path the path to decode
     * @param encoding the encodeing
     * @return decoded path
     */
    public static String decode(String path, String encoding) {
        try {
            return URLDecoder.decode(path, encoding);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException("Cannot decode: " + path + " [" + encoding + "]", e);
        }
    }
}

Related

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