Here you can find the source of toBitSet(String s, int length)
public static BitSet toBitSet(String s, int length)
//package com.java2s; //License from project: Apache License import java.util.BitSet; public class Main { public static BitSet toBitSet(String s, int length) { int len = s.length(); BitSet bs = new BitSet(length); for (int i = 0; i < len; i++) { if (s.charAt(i) == '1') bs.set(i);/*ww w. j ava2s. c o m*/ } return bs; } }