Code example for HttpException

0
          result = EntityUtils.toString(entity);
        } else { 
          throw new HttpException("Received empty body from HTTP response");
        } 
      } else { 
        throw new HttpException("Received non-OK status from server: " + response.getStatusLine());
      } 
      return result;
    } 
 
    @SuppressWarnings("unused") 
    public String post(String url, String body) throws IOException, HttpException {
      String result;
      HttpPost request = new HttpPost(url);
      HttpEntity bodyEntity = new StringEntity(body);
      request.setEntity(bodyEntity);
      HttpResponse response = execute(request);
      int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode == HttpStatus.SC_OK) {
        HttpEntity entity = response.getEntity();