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[] removeLengthByte(byte[] base) {
    byte[] value = new byte[base.length - 1];
    System.arraycopy(base, 1, value, 0, base.length - 1);
    return value;
}

From source file:Main.java

private static byte[] bwkey(byte[] key) {
    int len = key.length;
    int i = 16 - len;
    byte[] result = new byte[16];
    System.arraycopy(key, 0, result, 0, len);
    for (int j = len; j < i; j++) {
        result[j] = 0x00;//from w  w w .j  a v a2 s . c om
    }
    return result;
}

From source file:Main.java

public static String[] arrayAppend(String[] array1, String[] array2) {
    String[] finalArray = new String[array1.length + array2.length];
    System.arraycopy(array1, 0, finalArray, 0, array1.length);
    System.arraycopy(array2, 0, finalArray, array1.length, array2.length);
    return finalArray;
}

From source file:Main.java

public static int[] remove(int[] array, int start, int len) {
    int[] r = new int[array.length - len];
    System.arraycopy(array, 0, r, 0, start);
    System.arraycopy(array, start + len, r, start, array.length - start - len);
    return r;/*from  w w w . java 2  s . c om*/
}

From source file:Main.java

public static byte[] byteArraySlice(byte[] b, int offset, int length) {
    byte[] ret = new byte[length];
    System.arraycopy(b, offset, ret, 0, length);
    return ret;// ww  w. j  a  va 2s .co  m
}

From source file:Main.java

private static byte[] copyOfRange(byte[] source, int from, int to) {
    byte[] range = new byte[to - from];
    System.arraycopy(source, from, range, 0, range.length);
    return range;
}

From source file:Main.java

public static byte[] resizeArray(byte[] source, int len) {
    byte[] target = new byte[len];
    len = (source.length < len) ? source.length : len;
    System.arraycopy(source, 0, target, 0, len);
    return target;
}

From source file:Main.java

public static String[] concat(String[] a, String[] b) {
    String[] c = new String[a.length + b.length];
    System.arraycopy(a, 0, c, 0, a.length);
    System.arraycopy(b, 0, c, a.length, b.length);
    return c;// ww w  .  j a v a2 s. c  om
}

From source file:Main.java

public static byte[] cancat(byte[] a, byte[] b) {
    int alen = a.length;
    int blen = b.length;
    byte[] result = new byte[alen + blen];
    System.arraycopy(a, 0, result, 0, alen);
    System.arraycopy(b, 0, result, alen, blen);
    return result;
}

From source file:Main.java

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