Here you can find the source of toBits(int b)
public static final String toBits(int b)
//package com.java2s; public class Main { /** @see #toBits(int) */ private static String onBit = "*"; /** @see #toBits(int) */ private static String offBit = "."; public static final String toBits(int b) { return toBits(b, 8); }/*from www . j a v a 2 s . co m*/ public static final String toBits(int b, int n) { int mask = 0x0001 << (n - 1); //Debug.println(toHex8(mask)); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append((b & (mask >>> i)) != 0 ? onBit : offBit); //Debug.println(toHex8(mask >>> i)); } return sb.toString(); } }