批量判断网页是否NOT found

import java.net.HttpURLConnection;
import java.net.URL;

public class NetValible{


static String[] url = {"http://down.daw.so/daw/mhhy-yxd-0806.apk","http://down.daw.so/daw/mhhy-yxd-0806.ap"};
public static void main(String args[]) {
for(int i=1;i<url.length+1;i++){

System.out.println("第"+i+"个是:"+isValid(url[i-1]));

}

}
public static boolean isValid(String strLink){
URL url;
try{
url = new URL(strLink);
HttpURLConnection connt = (HttpURLConnection) url.openConnection();
connt.setRequestMethod("HEAD");
String strMes = connt.getResponseMessage();
if(strMes.compareTo("Not Found")==0){
return false;
}
connt.disconnect();

}catch(Exception e){

return false;
}
return true;
}

}

life is a jounery,yes
原文地址:https://www.cnblogs.com/CaptainLin/p/3979672.html