You can convert a decimal to binary using toBinaryString() method of Integer wrapper class as follows.

 int i = 42;
   String binstr = Integer.toBinaryString(i);