import java.net.URL;
import java.net.HttpURLConnection;
public class test2 {
private boolean isConnect(String url) {
boolean flag = false;
int counts = 0;
if (url == null || url.length() <= 0) {
return flag;
}
while (counts < 5) {
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
int state = connection.getResponseCode();
if (state == 200) {
flag = true;
}
break;
} catch (Exception ex) {
counts++;
continue;
}
}
return flag;
}
public static void main(String[] args) {
test2 check = new test2();
System.out.println(check.isConnect ("http://www.baidu.com/cozone/20/34/203441/images/148_60_1.gif"));
}
}