Java Array Range Copy copyOf(byte[] src, int length)

Here you can find the source of copyOf(byte[] src, int length)

Description

byte array copy.

License

Apache License

Parameter

Parameter Description
src src.
length new length.

Return

new byte array.

Declaration

public static byte[] copyOf(byte[] src, int length) 

Method Source Code

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

public class Main {
    /**/* w w  w  .  j a  v a 2  s .  co  m*/
     * byte array copy.
     * 
     * @param src src.
     * @param length new length.
     * @return new byte array.
     */
    public static byte[] copyOf(byte[] src, int length) {
        return copyOf(src, 0, length);
    }

    /**
     * byte array copy.
     * 
     * @param src
     * @param offset
     * @param length
     * @return
     */
    public static byte[] copyOf(byte[] src, int offset, int length) {
        byte[] dest = new byte[length];
        System.arraycopy(src, offset, dest, 0, length);
        return dest;
    }
}

Related

  1. copyOf(byte[] original, int newLength)
  2. copyOf(byte[] original, int newLength)
  3. copyOf(byte[] original, int newLength)
  4. copyOf(byte[] original, int newLength)
  5. copyOf(byte[] source, int newLength)
  6. copyOf(char[] array)
  7. copyOf(char[] source)
  8. copyOf(double[] array, int length)
  9. copyOf(double[] v, int newlength)