Revision as of 05:32, 23 November 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/**
 * 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

ECE462 Survivor

Seraj Dosenbach