你如何在Android中编码URL?
我以为是这样的:
final String encodedURL = URLEncoder.encode(urlAsString, "UTF-8");
URL url = new URL(encodedURL);
Run Code Online (Sandbox Code Playgroud)
如果我执行上述操作,则将http://in urlAsString替换为http%3A%2F%2Fin encodedURL,然后java.net.MalformedURLException在使用URL时获取 .
有没有逃脱推荐的方法<,>,"和&字符在普通的Java代码输出HTML时?(除了手动执行以下操作外,即).
String source = "The less than sign (<) and ampersand (&) must be escaped before using them in HTML";
String escaped = source.replace("<", "<").replace("&", "&"); // ...
Run Code Online (Sandbox Code Playgroud) 正如标题所说:哪个编码器会给我空间%20而不是+?我需要它为Android.java.net.URLEncoder.encode给出+