public static byte [ ] readBytes ( InputStream is ) throws IOException { try ( ByteArrayOutputStream bos = new ByteArrayOutputStream ( is . available ( ) ) ) { copy ( is , bos ) ; return bos . toByteArray ( ) ; } }
This method consumes an input stream and returns its content .