url Decode with URLDecoder - Java Network

Java examples for Network:URL

Description

url Decode with URLDecoder

Demo Code


//package com.java2s;

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

public class Main {
    public static void main(String[] argv) throws Exception {
        String input = "java2s.com";
        String charset = "java2s.com";
        System.out.println(urlDecode(input, charset));
    }/*from   w ww .j  av a 2  s.com*/

    /**
     * @param input
     * @param charset
     * @return
     */
    public static String urlDecode(String input, String charset) {
        try {
            return URLDecoder.decode(input, charset);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related Tutorials