Java Array Sub Array subArray(byte[] data, int offset, int length)

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

Description

Returns subarray of bytes.

License

Open Source License

Parameter

Parameter Description
data Array of bytes.
offset First byte of subarray in original array.
length Length of subarray.

Return

Array of bytes representing the subarray.

Declaration

public static byte[] subArray(byte[] data, int offset, int length) 

Method Source Code

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

public class Main {
    /**/* w w  w .  j a  v a  2s  .c om*/
     * Returns subarray of bytes.
     * 
     * @param data Array of bytes.
     * @param offset First byte of subarray in original array.
     * @param length Length of subarray.
     * @return Array of bytes representing the subarray.
     */
    public static byte[] subArray(byte[] data, int offset, int length) {
        byte[] subarray = new byte[length];

        System.arraycopy(data, offset, subarray, 0, length);

        return subarray;
    }
}

Related

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