Here you can find the source of toArray(BitSet bitset, int size)
Parameter | Description |
---|---|
bitset | set of bits to convert |
size | number of bits to convert. length() it not useful here, and size() may not give the number you want. |
public static boolean[] toArray(BitSet bitset, int size)
//package com.java2s; //License from project: Apache License import java.util.BitSet; public class Main { /**/*from w ww . j av a 2 s .c o m*/ * Convert a BitSet into an array of boolean. * * @param bitset set of bits to convert * @param size number of bits to convert. length() it not useful here, and size() may * not give the number you want. * @return result of conversion */ public static boolean[] toArray(BitSet bitset, int size) { boolean[] b = new boolean[size]; for (int i = 0; i < size; i++) b[i] = bitset.get(i); return b; } }