List of utility methods to do Byte Flip
byte | flipByte(byte b) flip Byte return (byte) (((b & 0x01) << 7) | ((b & 0x02) << 5) | ((b & 0x04) << 3) | ((b & 0x08) << 1) | ((b & 0x10) >> 1) | ((b & 0x20) >> 3) | ((b & 0x40) >> 5) | ((b & 0x80) >> 7)); |
byte[] | flipBytes(byte[] bytes) flip Bytes byte[] bt = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { bt[bytes.length - 1 - i] = bytes[i]; return bt; |
int | flipBytes(int data) flip Bytes int byte1 = data & 0xff; int byte2 = (data & 0xff00) >>> 8; int byte3 = (data & 0xff0000) >>> 16; int byte4 = (data & 0xff000000) >>> 24; data = byte1 << 24; data += byte2 << 16; data += byte3 << 8; data += byte4; ... |