Reputation: 63
Is there a way to concatenate byte array and int value in java. Any help is appreciated. All I could find was concatenating 2 arrays.
int res=somefunction(byte[] buf,..); now i want to concatenate the buf and the res. I can use String[] instead of byte[] if needed.
Upvotes: 0
Views: 171
Reputation: 2734
byte[] buf = ...;
int res = somefunction(buf);
byte[] buf2 = new byte[buf.length + 1];
System.arraycopy(buf, 0, buf2, 0, buf.length);
buf2[buf.length] = (byte)res;
buf = buf2;
Upvotes: 1