Here you can find the source of toBinaryString(int number, int length)
public static String toBinaryString(int number, int length)
//package com.java2s; //License from project: Open Source License public class Main { public static String toBinaryString(int number, int length) { String result = new String(Integer.toBinaryString(number)); while (result.length() < length) { result = '0' + result; }//from ww w . java 2 s . co m return result; } }