public static byte [ ] copyOfRange ( byte [ ] source , int from , int to ) { if ( source == null || from < 0 || to < 0 ) { return null ; } int length = to - from ; if ( length < 0 ) { return null ; } if ( source . length < from + length ) { return null ; } byte [ ] destination = new byte [ length ] ; System . arraycopy ( source , from , destination , 0 , length ) ; return destination ; }
Copy a range of a given byte array .