- 7
- 0
- 约1.16万字
- 约 10页
- 2018-11-21 发布于江苏
- 举报
判断url链接否有效
java判断一个链接是否有效 (2011年08月01日)
一、
使用java快速判断网页链接是否有效 收藏 /*** 判断链接是否有效* 输入链接* 返回true或者false*/public static boolean isValid(String strLink) {URL url;try {?? url = new URL(strLink);?? HttpURLConnection connt = (HttpURLConnection)url.openConnection();?? connt.setRequestMethod(HEAD);?? String strMessage = connt.getResponseMessage();?? if (strMpareTo(Not Found) == 0) {??? return false;?? }?? connt.disconnect();} catch (Exception e) {?? return false;}return true;}
二、
package test;??
import .*;??
public class riqi { ?? ?? ?? ???
public static void main(String[] args) { ?? ?? ??
原创力文档

文档评论(0)