Java URI Decode decode(String encodedURI)

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

Description

decode

License

Open Source License

Parameter

Parameter Description
encodedURI a parameter

Return

the decoded URI, as a String

Declaration

public static String decode(String encodedURI) 

Method Source Code

//package com.java2s;
/**//from www  .jav  a 2  s. c  o  m
 * Copyright (C) 2012 MediaShelf <http://www.yourmediashelf.com/>
 *
 * This file is part of uuid-datepath-idmapper.
 *
 * uuid-datepath-idmapper 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 3 of the License, or
 * (at your option) any later version.
 *
 * uuid-datepath-idmapper 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 uuid-datepath-idmapper.  If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    /**
     * 
     * @param encodedURI
     * @return the decoded URI, as a String
     */
    public static String decode(String encodedURI) {
        if (encodedURI.endsWith("%2E")) {
            encodedURI = encodedURI.substring(0, encodedURI.length() - 3) + ".";
        }
        try {
            return URLDecoder.decode(encodedURI, "UTF-8");
        } catch (UnsupportedEncodingException wontHappen) {
            throw new RuntimeException(wontHappen);
        }
    }
}

Related

  1. decode(String uri)
  2. decodeToUtf8(String uri)
  3. decodeUnreserved(URI address)
  4. decodeURI(CharSequence uriCharSequence, String charset)