Here you can find the source of toBinaryString(int a, int bits)
public static String toBinaryString(int a, int bits)
//package com.java2s; //License from project: Open Source License public class Main { public static String toBinaryString(int a, int bits) { return String.format("%" + bits + "s", Integer.toBinaryString(a)).replace(' ', '0'); }/* ww w. ja va2 s . com*/ }