code: public static String entityToString(HttpEntity entity) throws IOException {
          if (entity != null) {
              InputStream is = entity.getContent();
              return IOUtils.toString(is, "UTF-8");
          }
          return "";
      }
docs: Converts the http entity to string. If entity is null, returns empty string.
  @param entity
  @return
  @throws IOException