Java Utililty Methods Endian Swap

List of utility methods to do Endian Swap

Description

The list of methods to do Endian Swap are organized into topic(s).

Method

intswapEndian(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;
StringswapEndianHexString(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();
intswapEndianness(int i)
swap Endianness
return ((i >>> 24) & 0xFF) | ((i >> 8) & 0xFF00) | ((i << 8) & 0xFF0000) | ((i << 24) & 0xFF000000);