Java URL Decode decode(Object value)

Here you can find the source of decode(Object value)

Description

Decodes string encoded in UTF-8 (useful for request parameters, or url fragments)

License

Open Source License

Parameter

Parameter Description
value url fragment

Return

decoded String

Declaration

public static String decode(Object value) 

Method Source Code

//package com.java2s;
/*******************************************************************************
* Copyright 2010-2016 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
*
* This file is part of SITools2.//from   www  . j  a  v  a 2 s  .c o  m
*
* SITools2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SITools2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SITools2.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

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

public class Main {
    /**
     * Decodes string encoded in UTF-8 (useful for request parameters, or url fragments)
     * @param value url fragment
     * @return decoded String
     */
    public static String decode(Object value) {
        if (value == null) {
            return null;
        }

        try {
            return URLDecoder.decode(value.toString(), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }
}

Related

  1. addParam(Map properties, String strParams, boolean bDecodeString)
  2. decode( Map source, String encoding)
  3. decode(final String content, final String encoding)
  4. decode(final String s, final String enc)
  5. decode(final String string)
  6. decode(String content)
  7. decode(String encoded)
  8. decode(String encodeMsg)
  9. decode(String input)