List of utility methods to do Endian Swap
int | swapEndian(final int i) Converts an int from little endian to big endian, or vice versa. return ((i & 0xff) << 24) | ((i & 0xff00) << 8) | ((i >>> 8) & 0xff00) | ((i >>> 24) & 0xff);
|
byte[] | swapEndian2Bytes(short sEndian) Swap the endian-ness of two bytes. byte[] b = new byte[2]; b[0] = (byte) (sEndian >>> 8); b[1] = (byte) sEndian; return b; |
String | swapEndianHexString(String in) swap Endian Hex String StringBuilder sb = new StringBuilder(); for (int i = 0; i < in.length(); i += 2) { String s = in.substring(i, i + 2); sb.insert(0, s); return sb.toString(); |
int | swapEndianness(int i) swap Endianness return ((i >>> 24) & 0xFF) | ((i >> 8) & 0xFF00) | ((i << 8) & 0xFF0000) | ((i << 24) & 0xFF000000);
|