Java Array Sub Array subArray(byte[] byteArray, int beginIndex, int length)

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

Description

Returns a portion of the specified byte array.

License

Apache License

Parameter

Parameter Description
byteArray The byte array. Must not be null .
beginIndex The beginning index, inclusive. Must be zero or positive.
length The length. Must be zero or positive.

Return

The byte array portion.

Declaration

public static byte[] subArray(byte[] byteArray, int beginIndex, int length) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  ww  w .j a v  a  2s.  c  o  m
     * Returns a portion of the specified byte array.
     *
     * @param byteArray  The byte array. Must not be {@code null}.
     * @param beginIndex The beginning index, inclusive. Must be zero or
     *                   positive.
     * @param length     The length. Must be zero or positive.
     *
     * @return The byte array portion.
     */
    public static byte[] subArray(byte[] byteArray, int beginIndex, int length) {

        byte[] subArray = new byte[length];
        System.arraycopy(byteArray, beginIndex, subArray, 0, subArray.length);
        return subArray;
    }
}

Related

  1. subarray(byte[] array, int offset, int length)
  2. subarray(byte[] array, int startIndexInclusive, int endIndexExclusive)
  3. subarray(byte[] array, int startIndexInclusive, int endIndexExclusive)
  4. subArray(byte[] b, int offset, int length)
  5. subarray(byte[] b, int ofs, int len)
  6. subArray(byte[] data, int offset, int length)
  7. subArray(byte[] data, int offset, int length)
  8. subarray(byte[] in, int a, int b)
  9. subarray(byte[] in, int arg1, int arg2)