Here you can find the source of intToBinString(int val, int width)
public static String intToBinString(int val, int width)
//package com.java2s; //License from project: Open Source License public class Main { static String mZeroes = "00000000000000000000000000000000"; public static String intToBinString(int val, int width) { String str = Integer.toBinaryString(val); if (str.length() >= width) { return str; }//from w w w . j a va 2 s. com return mZeroes.substring(0, width - str.length()) + str; } }