code: public static String asString(final HttpResponse response, final String encoding) {
          if (response == null) {
              throw new NullPointerException();
          }
  
          final HttpEntity entity = response.getEntity();
          if (entity == null) {
              return null;
          }
  
          try {
              return EntityUtils.toString(entity, encoding);
          } catch (final Exception e) {
              return null;
          }
      }
docs: Converts a {@linkplain HttpResponse} to a String by calling {@link EntityUtils#toString(HttpEntity)} on its {@linkplain HttpEntity
  entity}.
  
  @param response
  the {@linkplain HttpResponse response} to convert.
  @param encoding
  the encoding to use for the conversion.
  @throws NullPointerException
  if the given response was null
  @return the response body as a String or {@code null}, if no
  response body exists or an error occurred while converting.