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:
01 02 03 04 05 06 07 08 09 10 11 | 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:
1 | 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
You can download the full source code of this example here:URLDecoderExample.zip