网上拷贝了一段给你,看是不是你想要的:1,设置get方法请求超时为 5 秒Java代码  
GetMethod getMethod=new GetMethod(url);      
getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,5000);   
Java代码 
GetMethod getMethod=new GetMethod(url);     
getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,5000);  GetMethod getMethod=new GetMethod(url);  
getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,5000);
  2,设置 Http 连接超时为5秒Java代码  
HttpClient httpClient=new HttpClient();    
 httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);   
Java代码 
<SPAN class=hilite1>HttpClient</SPAN> <SPAN class=hilite1>httpClient</SPAN>=new <SPAN class=hilite1>HttpClient</SPAN>();   
 <SPAN class=hilite1>httpClient</SPAN>.getHttpConnectionManager().getParams().setConnectionTimeout(5000);   HttpClient httpClient=new HttpClient();
  httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); 
设置连接超时和请求超时,这两个超时的意义不同,需要分别设置。