Browser URL encoding for &

Browser does not display urls with & character, to resolve this issue I wrote a method to convert & to its encoded value:

private String replaceSpecialChar(String originalImagePath)

{

int indexAmp = originalImagePath.indexOf("&");

if (indexAmp > -1)

originalImagePath = originalImagePath.replaceAll("&", "%26");

int indexSpace = originalImagePath.indexOf(" ");

if (indexSpace > -1)

originalImagePath = originalImagePath.replaceAll(" ", "%20");

return originalImagePath;

}



As an Amazon Associate I earn from qualifying purchases.

No comments:

Post a Comment

Post Scriptum

The views in this article are mine and do not reflect those of my employer.
I am preparing to cancel the subscription to the e-mail newsletter that sends my articles.
Follow me on:
X.com (Twitter)
LinkedIn
Google Scholar

Popular Recent Posts

Most Popular Articles

apt quotation..