URLDecoder

java.net.URLDecoder Example

URLDecoder is a utility class for HTML form decoding. This class contains static methods for decoding a String from the application/x-www-form-urlencoded MIME format.

Project Environment

This example was implemented using the following tools :

  • Eclipse 4.3 (Kepler)
  • JDK 1.4 or greater

1. Example of URLDecoder

We are going to decode string in this example. Create a java class named URLDecoderExample and paste the following code.

URLDecoderExample.java:

package com.example.javacodegeeks;

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

public class URLDecoderExample {
	public static void main(String args[])throws UnsupportedEncodingException
	{
		System.out.println(URLDecoder.decode("special+chars%3A+%26%25*+", "UTF-8"));
	}
}

In above example we are decoding string in UTF-8 format.

output:

special chars: &%* 

Download the source code

This was an example of URLDecoder in Java.

Download
You can download the full source code of this example here:URLDecoderExample.zip

Vaibhav Kulkarni

Vaibahv is PH.D candidate and holds masters degree in computer application. He is active contributor to Apache Software Foundation as well as openJDK.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button