java – Float to Byte Array Conversion


How can I be converting from float or integer (if that's possible) to a byte array in Java.

Let's say:

float x=180

Theoretically you would need to create 1 byte array with 2 positions. Is there any way to 'automate' this?



I put it on GitHub for future reference .

This would create an array with 4 positions. Bytes alone won't do much.

Documentation . There it shows the methods for dealing with the other types you might want. What this class does is just treat the data as if they were just bytes.

Scroll to Top