Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java equivalent of Buffer.BlockCopy

Tags:

java

vb.net

What is the Java equivalent of VB's Buffer.BlockCopy?

for (int i = 0; i < num5; i++) {
    int[] dst = new int[9];
    // Buffer.BlockCopy(bytes, (num2 + &HF8) + (i * 40), dst, 0, 40)
    byte[] buffer2 = new byte[dst[4] - 1];
    // Buffer.BlockCopy(bytes, dst(5), buffer2, 0, buffer2.Length)
}

Notice the commented out section... I don't know a Java equivalent to put there.

like image 922
Jire Avatar asked Dec 27 '22 06:12

Jire


1 Answers

If I understand this properly, I think you want System.arraycopy(). The JavaDoc for it can be found here.

A quick example would be:

int[] src = new int[3] {1,2,3};
int[] dst = new int[4];
System.arraycopy(src, 0, dst, 0, 3); // Copies all of src into dst starting at zero.
// Dst would be {1,2,3,0}
like image 59
Todd Avatar answered Jan 09 '23 09:01

Todd