Here you can find the source of decode(String value)
Parameter | Description |
---|---|
value | the <code>String</code> to decode |
String
public static String decode(String value)
//package com.java2s; //License from project: Apache License import java.net.URLDecoder; public class Main { /**//from w w w . j a v a 2 s . co m * */ private static final String DEFAULT_ENCODING = "UTF-8"; /** * {@link #decode(String, String)} with "UTF-8" encoding * * @param value * the <code>String</code> to decode * @return the newly decoded <code>String</code> */ public static String decode(String value) { return decode(value, DEFAULT_ENCODING); } /** * Decodes a <code>application/x-www-form-urlencoded</code> string using a specific encoding scheme. The supplied * encoding is used to determine what characters are represented by any consecutive sequences of the form * "<code>%<i>xy</i></code>". * <p/> * <em><strong>Note:</strong> The <a href= "http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars"> World * Wide Web Consortium Recommendation</a> states that UTF-8 should be used. Not doing so may introduce * incompatibilites.</em> * * @param value * the <code>String</code> to decode * @param encoding * The name of a supported encoding * @return the newly decoded <code>String</code> * @throws IllegalArgumentException * If character encoding needs to be consulted, but named character encoding is not supported */ public static String decode(String value, String encoding) throws IllegalArgumentException { String decodedValue = null; try { decodedValue = URLDecoder.decode(value, encoding); } catch (Exception e) { throw new IllegalArgumentException(e.getMessage()); } return decodedValue; } }