The easiest way is to use Long.toBinaryString but I think that's not the purpose of the thread;)
If you have a JDK you can also check the source of the toBinaryString-method there you can find a...