I have an int in a hex value, the problem now how I can get each byte of it.
int hex = 0xDF60;
What I want is:
int byte1 = 0xDF;
int byte2 = 0x60;
Already refer the answer from this question (Suggested by talex and andreas). But the result is not what I actually want:
byte[] bytes = ByteBuffer.allocate(4).putInt(0x9F16).array();
for (byte b : bytes) {
System.out.format("0x%x ", b);
}
Output:
0x00 0x00 0x-97 0x22
Assumed the output like that because the value is already in hex.
Thank you.