List of utility methods to do Binary Encode
String | toBinFromHexChar(final char hex) to Bin From Hex Char switch (hex) { case '0': return ("0000"); case '1': return ("0001"); case '2': return ("0010"); case '3': ... |
String | toBinFromOct(final String octSymbols) Transform a string of octal symbols to a string of binary symbols StringBuilder bits = new StringBuilder(octSymbols.length() * BITS_PER_OCT_DIGIT); for (int i = 0; i < octSymbols.length(); i++) { bits.append(toBinFromOctChar(octSymbols.charAt(i))); return (bits.toString()); |
String | toBinFromOctChar(final char oct) to Bin From Oct Char switch (oct) { case '0': return ("000"); case '1': return ("001"); case '2': return ("010"); case '3': ... |
String | toBinString(byte b) An byte as a string bit representation. return toBinString((int) b); |
String | toBinString(byte value) to Bin String StringBuilder sb = new StringBuilder(Integer.toBinaryString(Integer.valueOf(value & 0xff))); while (sb.length() < 8) sb.insert(0, '0'); return sb.toString(); |
String | toBinString(byte[] byteArray) to Bin String StringBuilder sb = new StringBuilder(); for (int byteNum = byteArray.length - 1; byteNum >= 0; byteNum--) { for (int bitNum = SIZE_IN_BITS - 1; bitNum >= 0; bitNum--) { if (bitAt(bitNum, byteArray[byteNum])) { sb.append("1"); } else { sb.append("0"); return sb.toString(); |
String | toBinString(int val, int minLength) to Bin String StringBuilder sb = new StringBuilder(32); while (val != 0) { sb.append((val & 0x1) == 0 ? '0' : '1'); val >>>= 1; while (sb.length() < minLength) { sb.append('0'); return sb.reverse().toString(); |