Example usage for java.lang System arraycopy

List of usage examples for java.lang System arraycopy

Introduction

In this page you can find the example usage for java.lang System arraycopy.

Prototype

@HotSpotIntrinsicCandidate
public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);

Source Link

Document

Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

Usage

From source file:Main.java

public static byte[] concatenateBytes(byte[] iv, byte[] cipher) {
    byte[] res = new byte[iv.length + cipher.length];
    System.arraycopy(iv, 0, res, 0, iv.length);
    System.arraycopy(cipher, 0, res, iv.length, cipher.length);
    return res;/* w  w w.  j a  v  a  2 s  . c  om*/
}

From source file:Main.java

public static byte[] deconcatenateBytes(byte[] input, byte[] iv) {
    byte[] res = new byte[input.length - iv.length];
    System.arraycopy(input, 0, iv, 0, iv.length);
    System.arraycopy(input, iv.length, res, 0, res.length);
    return res;/*ww  w.ja v a  2s.  c  o m*/
}

From source file:Main.java

public static byte[] append(byte[] org, byte[] to) {

    byte[] newByte = new byte[org.length + to.length];

    System.arraycopy(org, 0, newByte, 0, org.length);

    System.arraycopy(to, 0, newByte, org.length, to.length);

    return newByte;

}

From source file:Main.java

public static byte[] arrayComb(byte[] prep, byte[] after) {
    byte[] result = new byte[prep.length + after.length];
    System.arraycopy(prep, 0, result, 0, prep.length);
    System.arraycopy(after, 0, result, prep.length, after.length);
    return result;
}

From source file:Main.java

public static byte[] subByteArr(byte[] srcByteArr, int startIndex, int subLength) {
    byte[] desData = new byte[subLength];
    System.arraycopy(srcByteArr, startIndex, desData, 0, subLength);
    return desData;
}

From source file:Main.java

public static String bytesToString(byte[] bytes, int offset, int strLength) {
    byte[] stringBytes = new byte[strLength];
    System.arraycopy(bytes, offset, stringBytes, 0, strLength);
    //      return new String(Arrays.copyOfRange(bytes, offset, offset + strLength)).trim();
    return new String(stringBytes).trim();

}

From source file:Main.java

public static BigInteger OS2IP(byte[] _os) {
    byte[] _osWithPadding = new byte[_os.length + 1];
    System.arraycopy(_os, 0, _osWithPadding, 1, _os.length);
    return new BigInteger(_osWithPadding);
}

From source file:Main.java

public static byte[] subBytes(byte[] paramArrayOfByte, int paramInt1, int paramInt2) {
    byte[] arrayOfByte = new byte[paramInt2];
    System.arraycopy(paramArrayOfByte, paramInt1, arrayOfByte, 0, paramInt2);
    return arrayOfByte;
}

From source file:Main.java

public static String[] cloneSubarray(String a[], int from, int to) {
    int n = to - from;
    String result[] = new String[n];
    System.arraycopy(a, from, result, 0, n);
    return result;
}

From source file:Main.java

public static <T> T[] concatArrays(T[] a, T[] b) {
    T[] result = Arrays.copyOf(a, a.length + b.length);
    System.arraycopy(b, 0, result, a.length, b.length);
    return result;
}