Created
September 3, 2012 08:41
-
-
Save ytRino/3607934 to your computer and use it in GitHub Desktop.
InputStreamを丸々Stringにしちゃうやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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