ArrayUtils { public static byte[][] split(byte[] bytes, int splitIndex) { if (splitIndex < 0 || bytes.length < splitIndex) { throw new IllegalArgumentException("split index is out of range"); } final byte[] lhs = new byte[splitIndex]; final byte[] rhs = new byte[bytes.length - splitIndex]; System.arraycopy(bytes, 0, lhs, 0, lhs.length); System.arraycopy(bytes, splitIndex, rhs, 0, rhs.length); return new byte[][]{lhs, rhs}; }  static byte[][] split(byte[] bytes, int splitIndex); static int[] reverse(int[] input); static byte[] toByteArray(BigInteger value, int expectedBytesLength); static int[] toBinaryArray(BigInteger integer); static int[] toMutualOppositeForm(BigInteger integer);  }
@Test public void success_SplitByteArray_1() { byte[] input1 = new byte[]{19, -16, 82, 23, 24, -5, 62, 17, 82, 3, 67, 121, -16, -83, 14, 25, -13, 37, 13, -19, 20, 21, -82, 3, 94, -5, 26, 57, 18, 91, 110, 78}; byte[] result1 = ArrayUtils.split(input1, 10)[0]; byte[] result2 = ArrayUtils.split(input1, 10)[1]; assertThat(result1, is(new byte[]{19, -16, 82, 23, 24, -5, 62, 17, 82, 3})); assertThat(result2, is(new byte[]{67, 121, -16, -83, 14, 25, -13, 37, 13, -19, 20, 21, -82, 3, 94, -5, 26, 57, 18, 91, 110, 78})); }
@Test(expected = IllegalArgumentException.class) public void failure_SplitByteArray_wrong_expected_length_1() { byte[] input = new byte[]{1, 2, 3, 4, 5}; ArrayUtils.split(input, 8); }
@Test(expected = IllegalArgumentException.class) public void failure_SplitByteArray_wrong_range_1() { byte[] input = new byte[]{1, 2, 3, 4, 5, 6}; ArrayUtils.split(input, -1); }
@Test(expected = IllegalArgumentException.class) public void failure_SplitByteArray_wrong_range_2() { byte[] input = new byte[]{1, 2, 3, 4, 5, 6}; ArrayUtils.split(input, 9); }