title: BitSet to and from integer/long
body: <p>If I have an integer that I'd like to perform bit manipulation on, how can I load it into a <code>java.util.BitSet</code>?  How can I convert it back to an int or long?  I'm not so concerned about the size of the <code>BitSet</code> -- it will always be 32 or 64 bits long.  I'd just like to use the <code>set()</code>, <code>clear()</code>, <code>nextSetBit()</code>, and <code>nextClearBit()</code> methods rather than bitwise operators, but I can't find an easy way to initialize a bit set with a numeric type.</p>