Here you can find the source of swapEndianFormat(byte[] b)
public static byte[] swapEndianFormat(byte[] b)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] swapEndianFormat(byte[] b) { byte[] endianSwappedBytes = new byte[b.length]; for (int i = 0; i < b.length; i++) { endianSwappedBytes[i] = swapEndianFormat(b[i]); }/* w ww. ja v a2 s .c o m*/ return endianSwappedBytes; } private static byte swapEndianFormat(byte b) { int converted = 0x00; converted ^= (b & 0b1000_0000) >> 7; converted ^= (b & 0b0100_0000) >> 5; converted ^= (b & 0b0010_0000) >> 3; converted ^= (b & 0b0001_0000) >> 1; converted ^= (b & 0b0000_1000) << 1; converted ^= (b & 0b0000_0100) << 3; converted ^= (b & 0b0000_0010) << 5; converted ^= (b & 0b0000_0001) << 7; return (byte) (converted & 0xFF); } }