Here you can find the source of digitToBinary(int digit)
private static String digitToBinary(int digit)
//package com.java2s; public class Main { private static String digitToBinary(int digit) { return String.format("%4s", Integer.toBinaryString(digit)).replace( " ", "0"); }/* w w w . j a v a2s .co m*/ private static String digitToBinary(String digit) { return String.format("%4s", Integer.toBinaryString(Integer.valueOf(digit, 10))) .replace(" ", "0"); } }