Inserting byte values into byte array in Android Java
Posted on 2014-04-11
Example: I have a decimal value 43799883 which is 29C554B in hex. How can I insert the hex correctly into byte array and starting at a specific byte array location?
int test = 43799883;
byte[ ] testArray = new byte;
testArray = (byte) test;
Here, I want to start inserting the test value in byte starting at testArray location 10 and onward. Since 29C554B is 4 bytes long, I was expecting to see:
testArray = 29
testArray = C5
testArray = 54
testArray = B
But the result was that the last two digits of the hexadecimal value (4B) was entered into testArray.
Please provide help with the correct code.