HttpClient 总是报空指针异常
public class HttpClientThread extends Thread {
public String url;
public HttpClientThread(String url){
this.url = url;
}
public void run() {
// TODO Auto-generated method stub
HttpGet httpGet = new HttpGet();
HttpClient client = new DefaultHttpClient();
try {
HttpResponse response = client.execute(httpGet);
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK )
{
String contextString = EntityUtils.toString(response.getEntity());
System.out.println("==============>>"+contextString);
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}