Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I manipulate and make byte arrays?

Tags:

java

I'm creating packets, and I need to encode bytes into an array for output. I have not been able to find any convenient classes to buffer the bytes in a variable length array, and then output them as an array of bytes.

Any ideas?

like image 395
alexgolec Avatar asked Nov 21 '25 22:11

alexgolec


1 Answers

Use ByteArrayOutputStream write bytes into it, and then call toBytes() to get the bytes.

like image 58
Nishan Avatar answered Nov 23 '25 11:11

Nishan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!