DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Slurp InputStream To String
public static String slurp (InputStream in) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
return out.toString();
}






Comments
Carla Brian replied on Wed, 2012/07/18 - 9:21am
Bernd Juenger replied on Sun, 2007/06/17 - 11:16am
sb.append(line).append("\n");Snippets Manager replied on Thu, 2006/10/26 - 12:08pm
Snippets Manager replied on Wed, 2006/09/27 - 1:06pm
Krikava replied on Tue, 2006/08/08 - 11:36am
Snippets Manager replied on Wed, 2006/02/22 - 8:28pm