public static byte [ ] readAll ( InputStream source , int length ) throws IOException { byte [ ] ret = new byte [ length ] ; int readBytes = readAll ( source , ret , 0 , ret . length ) ; if ( readBytes < ret . length ) { throw new EOFException ( String . format ( "Was only able to read %d bytes, which is less than the requested length of %d." , readBytes , ret . length ) ) ; } return ret ; }
Reads a number of bytes from the given InputStream and returns it as the given byte array .