Reputation: 1971
I can not find an answer to that and I do not know how to compile org.apache.commons.lang.StringEscapeUtils
, which is the only solution I found on the internet.
Also, I do not understand why I can not do something like this
s = s.replaceAll(" ","\\ ");
Upvotes: 0
Views: 7908
Reputation: 5531
Use this:
String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
URL url = new URL(urlStr);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();
Source: Url encoding in Android
This should be the correct answer in that post.
Upvotes: 0
Reputation: 1477
I think you can use
URLEncoder.encode("your URL here", "UTF8")
Upvotes: 2