Java Array Sub Array subArray(byte[] array, int beginIndex, int endIndex)

Here you can find the source of subArray(byte[] array, int beginIndex, int endIndex)

Description

Extract a sub array of bytes out of the byte array.

License

Open Source License

Parameter

Parameter Description
array the byte array to extract from
beginIndex the beginning index of the sub array, inclusive
endIndex the ending index of the sub array, exclusive

Declaration

public static byte[] subArray(byte[] array, int beginIndex, int endIndex) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   w  w w.  j av  a  2s.co  m
     * Extract a sub array of bytes out of the byte array.
     * @param array the byte array to extract from
     * @param beginIndex the beginning index of the sub array, inclusive
     * @param endIndex the ending index of the sub array, exclusive
     */
    public static byte[] subArray(byte[] array, int beginIndex, int endIndex) {
        int length = endIndex - beginIndex;
        byte[] subarray = new byte[length];
        System.arraycopy(array, beginIndex, subarray, 0, length);
        return subarray;
    }
}

Related

  1. sub(String[] a, String[] b)
  2. sub(T[] source, int first, int last)
  3. subarray(boolean[] array, int fromIndex, int length)
  4. subArray(byte[] a, int beginIndex, int endIndex)
  5. subarray(byte[] array, int offset, int length)
  6. subarray(byte[] array, int startIndexInclusive, int endIndexExclusive)
  7. subarray(byte[] array, int startIndexInclusive, int endIndexExclusive)
  8. subArray(byte[] b, int offset, int length)