Friday, June 27, 2014

Why I Hate Java, pt. 1

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

Note: Only a member of this blog may post a comment.

Jekyll Pages List

Getting a list of pages in a Jekyll site is easy, but paring that down to just the top-level files and the index pages is tricky. {% for p...