Here you can find the source of toBin(long value, int width)
public static String toBin(long value, int width)
//package com.java2s; public class Main { public static String toBin(long value, int width) { char[] result = new char[width]; for (int cntr = 0; cntr < width; cntr++) result[width - cntr - 1] = (value & (0x1 << cntr)) == 0 ? '0' : '1'; return new String(result); }/* w ww .j a v a 2 s . co m*/ }