1 2 public static String slurp (InputStream in) throws IOException { 3 StringBuffer out = new StringBuffer(); 4 byte[] b = new byte[4096]; 5 for (int n; (n = in.read(b)) != -1;) { 6 out.append(new String(b, 0, n)); 7 } 8 return out.toString(); 9 }
public static String inputStreamAsString(InputStream stream)
throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
return sb.toString();
}
You need to create an account or log in to post comments to this site.