Code example for BasicResponseHandler

0
 
  protected String fetch(String url) throws Exception {
    HttpClient httpclient = new DefaultHttpClient();
    HttpGet request = new HttpGet(url);
 
    return httpclient.execute(request, new BasicResponseHandler());
  } 
 
  /** 
   * Fetch content from a url, but only if it's more recent than the 
   * lastModified parameter, which is a unix timestamp. 
   *  
   * @param url  
   * @param lastModified  
   * @return the content or null if the content hasn't been changed 
   * @throws Exception if something goes wrong or status code is > 300 && != 304 
   */ 
  protected String fetch(String url, long lastModified) throws Exception {
    HttpGet request = new HttpGet(url);
    request.setHeader("If-Modified-Since", DateUtils.formatDate(new Date(lastModified)));
Contextual code suggestions in your IDE  Get Codota for Java