Reputation: 1005
I'm getting an exception
saying Java URI Syntax Exception "java.io.IOException: java.net.URISyntaxException: Invalid % sequence: %wl in query at index 88:"
when i try to connect from my android application.
It seems to be throwing the exception
where in the URL it says "%wl"
and following is the URL. is there a work around for this.
http://192.168.111.111:9000/RB/db.svc/upd?LinkId=184617ED1F21&IPs=fe80::1a46:17ff:feed:1f21%wlan0,192.168.1.127,&MNo=0771111111&sPin=000&Status=0
Upvotes: 0
Views: 2511
Reputation: 15644
If you want to use %
in your URL the first you need to do is to encode it.
So first you need to replace that %
with %25
in your string ....1f21%wlan0...
with .....1f21%25wlan0....
before connecting.
You can use the following code for encoding the URL in Java
String encodedUrl = java.net.URLEncoder.encode(<your_url>,"UTF-8");
Have a look at the below links for more information.
2.URL encoding character reference
UPDATE :
If you don't want to use URL encoder then you can try this out :
yourURL.replaceAll("%", "%25");
It is fine here to replace a single special character, but it would be a tedious task to do like this if you have many special characters that require proper URL encoding.
Upvotes: 4