android URL中文和空格会报错解决方案
时间:2014-05-07 20:00:40
收藏:0
阅读:363
url = URLEncoder.encode(urlStr,"utf-8").replaceAll("\\+", "%20");
//encode会将空格替换为+号,所有要讲+号替换为空格的转义%20
url = url.replaceAll("%3A", ":").replaceAll("%2F", "/");
//encode会把url里的/和:这2个符号变成%2F和%3A 这里替换回来
评论(0)