Skip to content

Instantly share code, notes, and snippets.

@ytRino
Created September 3, 2012 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytRino/3607934 to your computer and use it in GitHub Desktop.
Save ytRino/3607934 to your computer and use it in GitHub Desktop.
InputStreamを丸々Stringにしちゃうやつ
text = client.execute(httpGet, new ResponseHandler<String>() {
@Override
public String handleResponse(HttpResponse resp)
throws ClientProtocolException, IOException {
if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getStatusCode() + "returned.");
}
HttpEntity entity = resp.getEntity();
if (entity != null) {
InputStream is = entity.getContent();
// woooooooooooooooooo!!
return new java.util.Scanner(is).useDelimiter("\\A").next();
}
return null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment