Menu

URL Encoding in Java

Java, Webservice By Oct 16, 2014 No Comments
Whenever we are passing data to any url or web services, some characters of the data might be un recognised. Hence, it is always better to encode data before sending to URLs or web services, which we call as URL encoding. We have pre defined apis in java to do this encoding.

 

Below is an example to show how to encode a string in java.

String str=”Hello World”;
java.net.URLEncoder..encode(str, “UTF-8”);

The output for this code would be:

Hello+World.

No Comments

Leave a comment

Hi, Welcome here.
JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.