Java Byte Array Copy copyBytes(byte[] arr, int length)

Here you can find the source of copyBytes(byte[] arr, int length)

Description

copy Bytes

License

Open Source License

Declaration

public static byte[] copyBytes(byte[] arr, int length) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] copyBytes(byte[] arr, int length) {
        byte[] newArr = null;
        if (arr == null || arr.length == length) {
            newArr = arr;/*  ww  w. j a v  a 2  s  . c  o  m*/
        } else {
            newArr = new byte[length];
            for (int i = 0; i < length; i++) {
                newArr[i] = (byte) arr[i];
            }
        }
        return newArr;
    }
}

Related

  1. copyByte(byte[] ASource, int nFrom, int nEnd)
  2. copyByteArray(byte[] array2Copy)
  3. copyByteArray(byte[] source)
  4. copyByteArray(final byte[] src, byte[] dest, int length)
  5. copyBytes(byte[] dst, int dstPos, int value)
  6. copyBytes(byte[] dstBytes, int dstFrom, byte[] srcBytes, int srcFrom, int len)
  7. copyBytes(byte[] from, byte[] to, int fromIndex)
  8. copyBytes(byte[] from, int offset, int len)