Hello all. I apologize in advance if this information is readily available, because I haven't been able to find a definitive answer to this question. I need to convert an int to a
big endian 4 byte-array. I have the following code, which I'm fairly sure works, but it's the big endian part I'm not sure about. Can anyone confirm that this code snippet will do what I expect:
public static final byte[] intToByteArray(int value)
{
return new byte[]
{
(byte)(value & 0xff),
(byte)(value >> 8 & 0xff),
(byte)(value >> 16 & 0xff),
(byte)(value >>> 24) };
}
}
Thank you very much in advance for your help.
-Kennedy