List of utility methods to do Byte Array Bit Get
byte | getBitData(byte[] src, int index) new byte[]{13, 0} => 00001101, 00000000 => 8 = 1, 10 = 1, 11 = 1 return getBitData(src, index, true);
|
byte | getBitData(byte[] src, int index, boolean isLH) get Bit Data return getBitData(src, index, index + 1, isLH)[0];
|
byte[] | getBitData(byte[] src, int start, int end) new byte[]{13, 0} => 00001101, 00000000 => 8-11 = new byte[]{1, 0, 1, 1} return getBitData(src, start, end, true);
|
byte[] | getBitData(byte[] src, int start, int end, boolean isLH) get Bit Data byte[] result = null; StringBuffer sb = new StringBuffer(); for (byte b : src) { sb.append(getBinaryString(b)); String bitString = (isLH ? sb : sb.reverse()).substring(start, end); result = new byte[bitString.length()]; for (int i = 0; i < bitString.length(); i++) { ... |
long | getByteNetOrder(byte[] theBytes, int idx, int size) Limited to max of 8 bytes long long sum = 0; for (int i = 0; i < size; i++) { sum = sum * 256 + (0xff & theBytes[i + idx]); return sum; |
int | getByteNetOrderTo_unit16(byte[] theBytes, int idx) pull out unsigned 16 bits integer out of the array. int sum = 0; for (int i = 0; i < 2; i++) { sum = (sum << 8) + (0xff & theBytes[i + idx]); return sum; |
long | getByteNetOrderTo_unit32(byte[] theBytes, int idx) pull out unsigned 32 bits int out of the array. long sum = 0; for (int i = 0; i < 4; i++) { sum = sum * 256 + (0xff & theBytes[i + idx]); return sum; |
byte[] | bitwiseAndByteArrays(byte[] arr0, byte[] arr1) bitwise And Byte Arrays byte[] returnArray = new byte[arr0.length]; for (int i = 0; i < arr0.length; i++) { returnArray[i] = (byte) (arr0[i] & arr1[i]); return returnArray; |
byte[] | bitwiseOrByteArrays(byte[] arr0, byte[] arr1) bitwise Or Byte Arrays byte[] returnArray = new byte[arr0.length]; for (int i = 0; i < arr0.length; i++) { returnArray[i] = (byte) (arr0[i] | arr1[i]); return returnArray; |
byte[] | inverseByteArrayBits(byte[] arr0) inverse Byte Array Bits byte[] returnArray = new byte[arr0.length]; for (int i = 0; i < arr0.length; i++) { returnArray[i] = (byte) ~arr0[i]; return returnArray; |