Java - Write code to do url decode

Requirements

Write code to do url decode

Decode using UTF-8

Hint

Use URLDecoder.decode() method

Demo

//package com.book2s;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class Main {
    public static void main(String[] argv) {
        String str = "http://book2s.com#$%^&*()";
        System.out.println(urldecode(str));
    }//w  ww .  java 2  s .co  m

    public static String urldecode(String str) {
        try {
            return URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException(e);
        }
    }
}