Java examples for java.util:BitSet
Convert a bitset to an integer value
//package com.java2s; import java.util.BitSet; public class Main { /**//from w w w .java 2 s.c o m * Convert a bitset to an integer value * @param bitSetValue The bitset to convert * @return the int value of a bit set */ public static int bitSetToInt(BitSet bitSetValue) { int returnInt = 0; // Loop through int size shifting bytes as needed for (int i = Integer.SIZE; i >= 0; i--) { if (bitSetValue.get(i)) { returnInt |= (1 << i); } } return returnInt; } }