URLEncoder with sample program

Sample program:

 

package com.ngdeveloper.com;

import java.io.UnsupportedEncodingException;
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(URLEncoder.encode(intro,"UTF-8"));

	}

}

 

Output:

I+am+naveen+kumar+working+%40+www.ngdeveloper.com

URLEncoder Rules:

All the characters (a to z & A to Z) and numbers (0 to 9) remains same.

Space is converted to “+”

All the other characters are converted to hexadecimal values by prefixing with %.

In the above sample program, %40 is the hexadecimal value for @ sign.

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

735 total views, 2 views today

About Mirthbees 679 Articles
Blogger, Innovator, Developer and Enterpreneur. Founder of GuruRecharge, Readymade online recharge script. Lead Developer in Bookrate.in

Be the first to comment

Leave a Reply

Your email address will not be published.


*


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