/**
 * 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

has a message for current ECE438 students.

Sean Hu, ECE PhD 2009