Java Array Sub Array subArray(byte[] input, int start)

Here you can find the source of subArray(byte[] input, int start)

Description

Generate a subarray of a given byte array.

License

Open Source License

Parameter

Parameter Description
input the input byte array
start the start index

Return

a subarray of input, ranging from start to the end of the array

Declaration

public static byte[] subArray(byte[] input, int start) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w  w  .  j  a  va2 s.com*/
     * Generate a subarray of a given byte array.
     *
     * @param input the input byte array
     * @param start the start index
     * @param end   the end index
     * @return a subarray of <tt>input</tt>, ranging from <tt>start</tt>
     *         (inclusively) to <tt>end</tt> (exclusively)
     */
    public static byte[] subArray(byte[] input, int start, int end) {
        byte[] result = new byte[end - start];
        System.arraycopy(input, start, result, 0, end - start);
        return result;
    }

    /**
     * Generate a subarray of a given byte array.
     *
     * @param input the input byte array
     * @param start the start index
     * @return a subarray of <tt>input</tt>, ranging from <tt>start</tt> to
     *         the end of the array
     */
    public static byte[] subArray(byte[] input, int start) {
        return subArray(input, start, input.length);
    }
}

Related

  1. subArray(byte[] data, int offset, int length)
  2. subArray(byte[] data, int offset, int length)
  3. subarray(byte[] in, int a, int b)
  4. subarray(byte[] in, int arg1, int arg2)
  5. subArray(byte[] in, int start, int end)
  6. subArray(byte[] source, int start, int len)
  7. subarray(byte[] src, int beginIndex)
  8. subArray(byte[] src, int offset, int len)
  9. subArray(byte[] src, int pos, int length)