代码
1 HttpGet httpGet = new HttpGet(url);
2 HttpParams httpParameters = new BasicHttpParams();
3  // Set the timeout in milliseconds until a connection is established.
4  int timeoutConnection = 3000;
5 HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
6  // Set the default socket timeout (SO_TIMEOUT)
7 // in milliseconds which is the timeout for waiting for data.
8 int timeoutSocket = 5000;
9 HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
10
11 DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
12 HttpResponse response = httpClient.execute(httpGet);
13

 

 

相关文章:

  • 2021-09-29
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-12-19
  • 2022-12-23
  • 2021-11-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案