URL编码转义,冒号和不转,否则导致http链接失效

URL编码转义,冒号和不转,否则导致http链接失效

2023年6月25日发(作者:)

URL编码转义,冒号和不转,否则导致http链接失效URL含有中⽂需要转义参考 /benbenxiongyuan/article/details/10608095⾃⼰写⼀个 1 public boolean checkURLFileIsExist(String stringURL){ 2 boolean isExist = false; 3 String sEncodeURL; 4

5 try{ 6 // URL内中⽂编码 7 String s2 = URIComponent(stringURL, "UTF-8"); 8 // :和/都会被编码,导致http链接就会失效处理 9 sEncodeURL = eAll("%3A", ":").replaceAll("%2F", "/");10 URL url = new URL(sEncodeURL);11 HttpURLConnection conn = (HttpURLConnection) nnection();12 int state = ponseCode();13 if(state == 200){14 isExist = true;15 }else{16 isExist = false;17 }18 }catch(Exception e){19 ("checkURLFileIsExist occur exception:" + e);20 isExist = false;21 return isExist;22 }23 return isExist;24 }

发布者:admin,转转请注明出处:http://www.yc00.com/web/1687677975a30800.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信