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