List of utility methods to do Byte to Binary
String | byteToBin(byte[] bs) byte To Bin char[] cs = new char[bs.length * 9]; for (int i = 0; i < bs.length; ++i) { byte b = bs[i]; int j = i * 9; cs[j] = (((b >>> 7 & 0x1) == 1) ? 49 : '0'); cs[(j + 1)] = (((b >>> 6 & 0x1) == 1) ? 49 : '0'); cs[(j + 2)] = (((b >>> 5 & 0x1) == 1) ? 49 : '0'); cs[(j + 3)] = (((b >>> 4 & 0x1) == 1) ? 49 : '0'); ... |
String | byteToBinary(byte value) Return a binary string representation of the byte. return String.format("%8s", Integer.toBinaryString(value & 0xFF)).replace(' ', '0'); |
String | byteToBinaryStr(byte b) byte To Binary Str int v = b & 0xFF; return byteToBinaryStr(v); |
String | byteToBinaryString(byte i) byte To Binary String StringBuilder result = new StringBuilder(); result.append(getBit(i, 8)); result.append(getBit(i, 7)); result.append(getBit(i, 6)); result.append(getBit(i, 5)); result.append(" "); result.append(getBit(i, 4)); result.append(getBit(i, 3)); ... |
String | byteToBinaryString(byte toString) byte To Binary String String string = ""; String s = String.format("%8s", Integer.toBinaryString(toString & 0xFF)).replace(' ', '0'); string += s; return string; |