/**
* File Name:HttpClient.java
* Package Name:com.base.http
*
*/
package com.base.util;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service;
/**
*
* @version
* @since JDK 1.6
* @see
*/
@Service
public class HttpClientUtil {
public String getHttpContent(String url) throws IOException,
ClientProtocolException {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null)
return EntityUtils.toString(httpEntity);
return null;
}
}
* File Name:HttpClient.java
* Package Name:com.base.http
*
*/
package com.base.util;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service;
/**
*
* @version
* @since JDK 1.6
* @see
*/
@Service
public class HttpClientUtil {
public String getHttpContent(String url) throws IOException,
ClientProtocolException {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null)
return EntityUtils.toString(httpEntity);
return null;
}
}