Advertisement
n0tmE

android: IOUtils - read from InputStream into String

Jul 22nd, 2011
1,111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3.  
  4. public class IOUtils {
  5.     public static String readInputStream(InputStream is) throws IOException {
  6.         StringBuffer stream = new StringBuffer();
  7.         byte[] b = new byte[4096];
  8.         for (int n; (n = is.read(b)) != -1;) {
  9.             stream.append(new String(b, 0, n));
  10.         }
  11.         return stream.toString();
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement