Hello!

Can someone please suggest a way to effectively copy the bytes from one array to another.
In my program a user will call the method setDate(byte[] buf) which will set data continuously ie
inside the method there is an array say buf2.
for example if the method is called with 2 bytes as argument. then it is copied to buf2.
if again the method is called with 4 bytes as arguments. then data is stored in buf2[2] ... buf2[5] using for loop.
If the argument is of 10000 bytes then the performance is hit. Can you please suggest a faster way or algorithm to copy bytes from one array to another

Have you tried System.arraycopy() ?

o thanks!! I think this should work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.