我正在对字符串进行 URL 编码。当前代码将空格变成 "+" 而不是 "%20" 。我怎样才能更改代码来执行此操作?
代码:
httpURLEncoded = URLEncoder.encode(httpUrl, StandardCharsets.UTF_8.toString());
HttpGet getRequest = new HttpGet(httpURLEncoded);
getRequest.setHeader("Content-type", "application/json");
Goal: ABC%20XYZ instead of ABC+XYZ
我认为 UTF 8 是正确的,它应该有所不同吗?
资源: