Try this, instead ....&message=hi%26hello....
. I mean, encode it.
[Edited]
As you said you have no control over it, and it is legacy application and they cannot fix it; then you can still, I suppose, use URLEncoder
to encode the URL.
String encodedUrl = URLEncoder.encode(url, "UTF-8");
// Then use encodedUrl as you were using url.
[Edited]
..or just treat it as a String
. Simple, isn't it?
// Please refactor.
String[] paramPart = url.split("?");
String[] params = paramPart[1].split("&");
Map<String, String> paraMap = new HashMap<>();
for(int i=0; i<params.length; i++) {
String[] keyValue;
if(params[i].contains("=")) {
keyValue = params[i].split("=");
paraMap.put(keyValue[0], keyValue[1]);
} else {
params[i-1] = params[i-1] + "&" + params[i];
keyValue = params[i-1].split("=");
paraMap.put(keyValue[0], keyValue[1]);
}
}