Here you can find the source of longToBitSet(long bits)
public static BitSet longToBitSet(long bits)
//package com.java2s; import java.util.BitSet; public class Main { public static BitSet longToBitSet(long bits) { BitSet ret = new BitSet(); for (int count = 0;; count++) { long curBit = 1L << count; ret.set(count, (bits & curBit) != 0); if (curBit >= bits) break; }//from w w w. j av a 2s.co m return ret; } }