private static void validateLength ( byte [ ] data , String dataName , int expectedLength ) throws IllegalArgumentException { if ( data . length != expectedLength ) { throw new IllegalArgumentException ( String . format ( "Invalid %s length. Expected %d bytes but found %d." , dataName , expectedLength , data . length ) ) ; } }
Checks the length of a byte array .