Java URLDecoder sample program

Java URLDecoder sample program

Program:

package com.ngdeveloper.com;

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

public class ComparePrintandSystem {
		static String intro="I am naveen kumar working @ www.ngdeveloper.com";
	public static void main(String[] args) throws UnsupportedEncodingException {
		System.out.println("Input string is "+intro);
		String encodedurl = URLEncoder.encode(intro,"UTF-8");
		System.out.println("After encoding the INPUT " +encodedurl);
		String decodedurl = URLDecoder.decode("After decoding the encoded input "+encodedurl,"UTF-8");
		System.out.println(decodedurl);
	}

}

 

 Output:

Input string is I am naveen kumar working @ www.ngdeveloper.com
After encoding the INPUT I+am+naveen+kumar+working+%40+www.ngdeveloper.com
After decoding the encoded input I am naveen kumar working @ www.ngdeveloper.com

Screenshot for your reference:

 

Thanks for reading this post…………..!!!

 

 

569 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *