How do I read an entire InputStream into a byte array?
InputStream
Input Stream is ... ByteArrayOutputStream bos = new ByteArrayOutputStream(); int next = in.read(); while (next > -1) { bos.write(next); next = in.read(); } bos.flush(); byte[] result = bos.toByteArray(); bos.close();