Here you can find the source of subarray(byte[] in, int a, int b)
a
to index b
and of size (b-a)
.
Parameter | Description |
---|---|
in | input array |
a | first index |
b | last index |
public static byte[] subarray(byte[] in, int a, int b)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w .jav a 2 s. c o m * Creates and returns a new array with the values of the original from index <code>a</code> to index <code>b</code> * and of size <code>(b-a)</code>. * @param in input array * @param a first index * @param b last index * @return a new array based on the desired range of the input */ public static byte[] subarray(byte[] in, int a, int b) { if (b - a > in.length) return in;// TODO better error checking byte[] out = new byte[(b - a) + 1]; for (int i = a; i <= b; i++) { out[i - a] = in[i]; } return out; } }