@Test public void testSplit() { byte[] in = new byte[] {0, 0, 1, 1, 1, 1, 0, 0}; byte[] out = ByteUtil.split(in, 2, 6); Assert.assertArrayEquals(new byte[] {1, 1, 1, 1}, out); System.out.println(String.format("[CRAFT-ATOM-UTIL] (^_^) <%s> Case -> make split. ", CaseCounter.incr(1))); }
public static byte[] split(byte[] bytes, int start, int end) { if (bytes == null) { return null; } if (start < 0) { throw new IllegalArgumentException("start < 0"); } if (end > bytes.length) { throw new IllegalArgumentException("end > size"); } if (start > end) { throw new IllegalArgumentException("start > end"); } int len = end - start; byte[] dest = new byte[len]; System.arraycopy(bytes, start, dest, 0, len); return dest; }
ByteUtil { public static byte[] split(byte[] bytes, int start, int end) { if (bytes == null) { return null; } if (start < 0) { throw new IllegalArgumentException("start < 0"); } if (end > bytes.length) { throw new IllegalArgumentException("end > size"); } if (start > end) { throw new IllegalArgumentException("start > end"); } int len = end - start; byte[] dest = new byte[len]; System.arraycopy(bytes, start, dest, 0, len); return dest; } }
ByteUtil { public static byte[] split(byte[] bytes, int start, int end) { if (bytes == null) { return null; } if (start < 0) { throw new IllegalArgumentException("start < 0"); } if (end > bytes.length) { throw new IllegalArgumentException("end > size"); } if (start > end) { throw new IllegalArgumentException("start > end"); } int len = end - start; byte[] dest = new byte[len]; System.arraycopy(bytes, start, dest, 0, len); return dest; } private  ByteUtil(); }
ByteUtil { public static byte[] split(byte[] bytes, int start, int end) { if (bytes == null) { return null; } if (start < 0) { throw new IllegalArgumentException("start < 0"); } if (end > bytes.length) { throw new IllegalArgumentException("end > size"); } if (start > end) { throw new IllegalArgumentException("start > end"); } int len = end - start; byte[] dest = new byte[len]; System.arraycopy(bytes, start, dest, 0, len); return dest; } private  ByteUtil(); static int indexOf(final byte[] source, final byte[] target); static int indexOf(final byte[] source, final byte[] target, int fromIndex); static int indexOf(final byte[] source, final byte[] target, int fromIndex, int endIndex); static int indexOf(byte[] source, byte target); static int indexOf(byte[] source, byte target, int fromIndex); static int indexOf(byte[] source, byte target, int fromIndex, int endIndex); static byte[] split(byte[] bytes, int start, int end); static byte[] reverse(byte[] src); static String asHex(byte[] bytes); static String asHex(byte[] bytes, String separator); static byte[] intToNetworkByteOrder(int num, int count); static int networkByteOrderToInt(byte[] buf); static int networkByteOrderToInt(byte[] buf, int start, int count); static boolean isEmpty(byte[] bytes); static final short bytes2short(byte[] b); static final short bytes2short(byte[] b, int off); static final byte[] short2bytes(short s); static void short2bytes(short s, byte[] b, int off); static final int bytes2int(byte[] b); static final int bytes2int(byte[] b, int off); static final byte[] int2bytes(int i); static void int2bytes(int i, byte[] b, int off); static final long bytes2long(byte[] b); static final long bytes2long(byte[] b, int off); static final byte[] long2bytes(long l); static void long2bytes(long l, byte[] b, int off); static float bytes2float(byte[] b); static float bytes2float(byte[] b, int off); static final byte[] float2bytes(float f); static void float2bytes(float f, byte[] b, int off); static double bytes2double(byte[] b); static double bytes2double(byte[] b, int off); static final byte[] double2bytes(double d); static void double2bytes(double d, byte[] b, int off); static final int makeIntFromByte2(byte[] b); static final int makeIntFromByte2(byte[] b, int off); static final int makeIntFromByte4(byte[] b); static final int makeIntFromByte4(byte[] b, int off); }
ByteUtil { public static byte[] split(byte[] bytes, int start, int end) { if (bytes == null) { return null; } if (start < 0) { throw new IllegalArgumentException("start < 0"); } if (end > bytes.length) { throw new IllegalArgumentException("end > size"); } if (start > end) { throw new IllegalArgumentException("start > end"); } int len = end - start; byte[] dest = new byte[len]; System.arraycopy(bytes, start, dest, 0, len); return dest; } private  ByteUtil(); static int indexOf(final byte[] source, final byte[] target); static int indexOf(final byte[] source, final byte[] target, int fromIndex); static int indexOf(final byte[] source, final byte[] target, int fromIndex, int endIndex); static int indexOf(byte[] source, byte target); static int indexOf(byte[] source, byte target, int fromIndex); static int indexOf(byte[] source, byte target, int fromIndex, int endIndex); static byte[] split(byte[] bytes, int start, int end); static byte[] reverse(byte[] src); static String asHex(byte[] bytes); static String asHex(byte[] bytes, String separator); static byte[] intToNetworkByteOrder(int num, int count); static int networkByteOrderToInt(byte[] buf); static int networkByteOrderToInt(byte[] buf, int start, int count); static boolean isEmpty(byte[] bytes); static final short bytes2short(byte[] b); static final short bytes2short(byte[] b, int off); static final byte[] short2bytes(short s); static void short2bytes(short s, byte[] b, int off); static final int bytes2int(byte[] b); static final int bytes2int(byte[] b, int off); static final byte[] int2bytes(int i); static void int2bytes(int i, byte[] b, int off); static final long bytes2long(byte[] b); static final long bytes2long(byte[] b, int off); static final byte[] long2bytes(long l); static void long2bytes(long l, byte[] b, int off); static float bytes2float(byte[] b); static float bytes2float(byte[] b, int off); static final byte[] float2bytes(float f); static void float2bytes(float f, byte[] b, int off); static double bytes2double(byte[] b); static double bytes2double(byte[] b, int off); static final byte[] double2bytes(double d); static void double2bytes(double d, byte[] b, int off); static final int makeIntFromByte2(byte[] b); static final int makeIntFromByte2(byte[] b, int off); static final int makeIntFromByte4(byte[] b); static final int makeIntFromByte4(byte[] b, int off);  }