Here you can find the source of convertIntToBits(int num)
public static String convertIntToBits(int num)
//package com.java2s; //License from project: Open Source License public class Main { public static String convertIntToBits(int num) { StringBuilder builder = new StringBuilder(); while (num != 0) { if ((num & 0x1) == 1) builder.insert(0, '1'); else//from w w w.ja v a2 s . co m builder.insert(0, '0'); num >>>= 1; } return builder.toString(); } }