ydnas
ydnas

Reputation: 519

"&" Symbol in String of my class is not considered as a part of it

I have a String s="&0_o10&";

I am using this string in a webservice call as url. This string is a part of the url.I have dubugged the code , but its taking the string as "0_o10" instead of "&0_o10&".

Please help me .

Upvotes: 2

Views: 76

Answers (1)

La bla bla
La bla bla

Reputation: 8718

When dealing with URLs, if they contain anything that isn't a letter or a number, they should be encoded prior to using them.

Use:

String encodedUrl = URLEncoder.encode("&0_o10&", "UTF-8");

should result in something like %260_o10%26 that can be used with the webservice

Upvotes: 2

Related Questions