How do I read an entire InputStream into a byte array?
InputStream
Java 9 will give you finally a nice method:
InputStream in = ...; ByteArrayOutputStream bos = new ByteArrayOutputStream(); in.transferTo( bos ); byte[] bytes = bos.toByteArray();