posted 13 years ago
Hi,
I want to send a int value to server in little endian so it should be converted to uint32. I have this method to convert from big endian to little endian. Can I run an endian converter on a byte array? Please let me know.
public static byte[] convertBigEndianToLittleEndianByteArray(int i)
{
ByteBuffer buffer = ByteBuffer.allocate(4);
buffer.order(ByteOrder.LITTLE_ENDIAN).putInt(i);
byte [] b = buffer.array();
System.out.print("Little endian buffer of " + i + " = ");
for(int x=0; x<b.length; x++) System.out.print(b[x] + " ");
System.out.println();
return b;
}
Thanks,