Java Array Clone clone(final byte[] array)

Here you can find the source of clone(final byte[] array)

Description

Clones an array of bytes.

License

Open Source License

Parameter

Parameter Description
array the array to be cloned

Return

a new array filled with the elements of the argument array

Declaration

public static byte[] clone(final byte[] array) 

Method Source Code

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

public class Main {
    /**/*w w  w .ja v  a 2 s  .co m*/
     * Clones an array of bytes.
     * 
     * @param array the array to be cloned
     * @return a new array filled with the elements of the argument array
     */
    public static byte[] clone(final byte[] array) {
        return clone(array, 0, array.length);
    }

    /**
     * Clones a segment of an array of bytes.
     * 
     * @param array the array with the segment to be cloned
     * @param start the initial position of the segment
     * @param length the lenght of the segment to be cloned
     * @return a new byte array filled with the elements corresponding to the specified
     *         segment
     */
    public static byte[] clone(final byte[] array, final int start, final int length) {
        final byte[] result = new byte[length];
        System.arraycopy(array, start, result, 0, length);
        return result;
    }
}

Related

  1. clone(byte[] orig)
  2. clone(byte[][] im)
  3. clone(double[] array)
  4. clone(double[] p)
  5. clone(double[][] source)
  6. clone(final double[][] array)
  7. clone(final int[] original)
  8. clone(final T[] array)
  9. clone(final T[] array)