How do I read an entire InputStream into a byte array?
InputStream
Java 7 and later:
import sun.misc.IOUtils; ... InputStream in = ...; byte[] buf = IOUtils.readFully(in, -1, false);