62,614
社区成员
发帖
与我相关
我的任务
分享
public static boolean test(){
try {
// Create a URLConnection object for a URL
URL url = new URL("http://yoururl");
URLConnection conn = url.openConnection();
for (int i = 0;; i++) {
String headerName = conn.getHeaderFieldKey(i);
String headerValue = conn.getHeaderField(i);
if (headerName == null && headerValue == null) {
// No more headers
break;
}
if (headerName == null) {
if (headerValue.contains("200")){
return true;
}
}
}
} catch (Exception e) {
}
return false;
}