ToBinary reads whole numbers until a negative number ends the input. For each number it prints its binary form, the number of bits and how many of them are 1.
Build the binary form yourself, without Integer.toBinaryString: the remainder of the division by 2 is the last bit; divide by 2 and repeat until nothing is left. For the input
13 255 0 1024 7 -1
the program prints
13 = 1101 (4 bits, 3 ones)
255 = 11111111 (8 bits, 8 ones)
0 = 0 (1 bits, 0 ones)
1024 = 10000000000 (11 bits, 1 ones)
7 = 111 (3 bits, 3 ones)