/**
* HTTP GET方式
*
* @param url
* @return
* @throws IOException
* @throws ClientProtocolException
*/
public static String sendHttpForGet(String url) throws ClientProtocolException, IOException {
HttpClient client = null;
try {
client = new DefaultHttpClient();
client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, httpClientConnectionTimeout);
client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, httpClinetSoTimeout);
HttpGet get = new HttpGet(url);
HttpResponse httpResponse = client.execute(get);
String respData = EntityUtils.toString(httpResponse.getEntity());
return respData;
} finally {
client.getConnectionManager().shutdown();
}
}
* HTTP GET方式
*
* @param url
* @return
* @throws IOException
* @throws ClientProtocolException
*/
public static String sendHttpForGet(String url) throws ClientProtocolException, IOException {
HttpClient client = null;
try {
client = new DefaultHttpClient();
client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, httpClientConnectionTimeout);
client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, httpClinetSoTimeout);
HttpGet get = new HttpGet(url);
HttpResponse httpResponse = client.execute(get);
String respData = EntityUtils.toString(httpResponse.getEntity());
return respData;
} finally {
client.getConnectionManager().shutdown();
}
}