Decode a URL with parameters in Java

Description

The following code shows how to decode a URL with parameters.

Example


import java.net.URLDecoder;
/*from ww  w.  j  a v  a 2  s .  c o m*/
public class Main {

  public static void main(String[] args) {

    String input = "http://www.java2s.com/query?pg=q&kl=XX&stype=stext&q=%2B%22Java+Programming%22&search.x=30&search.y=7";
    System.out.println(input);
    try {
      String output = URLDecoder.decode(input, "UTF8");
      System.out.println(output);
    } catch (Exception e) {
      System.err.println("Malformed URL");
    }

  }

}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode