Code example for DefaultHttpClient

0
import org.apache.http.client.HttpClient; 
import org.apache.http.client.methods.HttpGet; 
import org.apache.http.impl.client.DefaultHttpClient; 
 
public class ApacheHttpClientExample { 
  final HttpClient httpClient = new DefaultHttpClient();
 
  public void get(String url) throws IOException {
    HttpResponse response = httpClient.execute(new HttpGet(url));
    printResponse(response.getEntity().getContent());
  } 
 
  private void printResponse(InputStream in) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    for (String line; (line = reader.readLine()) != null; ) {
      System.out.println(line);
    } 
  } 
 
  public static void main(String[] args) throws IOException {
Contextual code suggestions in your IDE  Get Codota for Java