To get the body of an HttpResponse as a string, you have to do this:
HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); InputStreamReader contentReader = new InputStreamReader(content); BufferedReader reader = new BufferedReader(contentReader); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); }
Am I the first person on the internet to ever do this?
Why on earth isn't there a convenience method like getEntityText()
or something?
No comments:
Post a Comment