/**
 * Convert the byte into binary form of string.
 * @param b
 * @return
 */
public static String convertByteToBinary(byte b) {
	StringBuilder result = new StringBuilder();
	for (int i = 0; i < 8; i++) {
		if (((b >> (7 - i)) & 0x1) == 1) {
			result.append(1);
		} else {
			result.append(0);
		}
	}
	return result.toString();
}


Back to JavaHowTo

Alumni Liaison

BSEE 2004, current Ph.D. student researching signal and image processing.

Landis Huffman