Java BitSet toBitSet(String s, int length)

Here you can find the source of toBitSet(String s, int length)

Description

to Bit Set

License

Apache License

Declaration

public static BitSet toBitSet(String s, int length) 

Method Source Code


//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;
    }
}

Related

  1. toArray(BitSet bitset, int size)
  2. toBitSet(byte[] array)
  3. toBitSet(byte[] bytes)
  4. toBitSet(final byte[] bytes)
  5. toBitSet(String data)
  6. toByteArray(BitSet bits)
  7. toByteArray(BitSet bits)
  8. toByteArray(BitSet bits, int fixedNumBytes)
  9. toByteArray(BitSet bits, int sizeInBytes)