package com.example.administrator.tv51365.utils; 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 java.io.IOException; /** * Created by Administrator on 2016/3/1 0001. */ public class HttpConnection { public String GetWebConnection(String url) { String result=null; try { HttpGet get=new HttpGet(url); HttpClient client=new DefaultHttpClient(); HttpResponse response=client.execute(get); if(response.getStatusLine().getStatusCode()==200){ result= EntityUtils.toString(response.getEntity()); System.out.println("HttpConnection**************************"+result); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result; } }