C
C
Chvalov2015-09-10 11:16:26
Java
Chvalov, 2015-09-10 11:16:26

How in my case to send an array with an array?

There is an array of type byte with data.
byte[] outByte = new byte[60];
I need to send it along with this:
send(new byte[]{1, (byte)144, 0, });After 144, 0, I NEED TO INSERT ALL DATA FROM MY ARRAY
of type something like this send(new byte[]{1, (byte)144, 0, outByte});
but I still don't understand how to do it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
moryakov, 2015-09-10
@Chvalov

just need to glue two arrays?

java.nio.ByteBuffer bb = java.nio.ByteBuffer.allocate(3+outByte.length);
bb.put(newArray);
bb.put(outByte);
send(bb.array());

P
protven, 2015-09-10
@protven

ArrayUtils.addAll(<first array>, <second array>)
from here https://commons.apache.org/proper/commons-collections/ . The easiest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question