Here you can find the source of bitSetToLong(BitSet set)
public static long bitSetToLong(BitSet set)
//package com.java2s; import java.util.BitSet; public class Main { public static long bitSetToLong(BitSet set) { int max = set.length(); long bits = 0; for (int count = 0; count < max; count++) { if (set.get(count)) bits |= (1L << count); }//from ww w . j a v a 2 s . c o m return bits; } }