我正在编写一个多次查询geoplugin的IP数据库的应用程序,偶尔会出现java.net.connectexception connection refused
{如果我发送150请求,最多10个可能会被拒绝)
我发送的请求是这样的:
private String getContent(URL url) throws Exception {
HttpURLConnection http = (HttpURLConnection) url.openConnection ();
http.connect ();
int code = http.getResponseCode();
if(code != 200) throw new RuntimeException("Failed to get the location. Http Status code : " + code);
return this.getContent(http);
}
网址格式为:
http://www.geoplugin.net/json.gp?ip=xx.xx.xx.xx
是否有一种简单的方法可以继续重新发送请求,直到它们被接受为止?