大家好!
   我用Java httpClient写了一个用测试代理服务的程序,现在有一个问题,请大家帮我解决一下,谢谢!
   我的代码是:
public String getHtmlCodeByProxy (String proxyip, int proxyport, String type) throws Exception {
String str="";
      try {
//创建http客户端
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setProxy(proxyip, proxyport);
// 使用POST方法
GetMethod getMethod = new GetMethod(Global.CLIENT_URL);
int statusCode = httpClient.executeMethod(getMethod);
if (statusCode == HttpStatus.SC_OK) {
str = getMethod.getResponseBodyAsString();
}
} catch (ConnectException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
错误信息是:
2009-12-9 16:03:43 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: I/O exception (java.net.ConnectException) caught when processing request:
Connection timed out: connect
2009-12-9 16:03:43 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: Retrying request
我想问在代理无效的情况下,怎样捕获这个错误消息;谢谢!