Java URL Decode decode(String value, String charset)

Here you can find the source of decode(String value, String charset)

Description

decode

License

Apache License

Declaration

public static String decode(String value, String charset) 

Method Source Code


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

import java.io.*;

import java.net.URLDecoder;

public class Main {
    public static final String DEFAULT_CHARSET = "UTF-8";

    public static String decode(String value) {
        return decode(value, DEFAULT_CHARSET);
    }//from w  ww .j  a  va2 s.  c  o  m

    public static String decode(String value, String charset) {
        String result = null;
        if (!isEmpty(value)) {
            try {
                result = URLDecoder.decode(value, charset);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    private static boolean isEmpty(final String str) {
        return str == null || str.length() == 0;
    }
}

Related

  1. decode(String value)
  2. decode(String value)
  3. decode(String value)
  4. decode(String value)
  5. decode(String value, String charset)
  6. decode(String value, String encoding)
  7. decodeAjax(String value)
  8. decodeAjaxParam(final String source)
  9. decodeArray(final String val)