BitSet To Byte - Java java.util

Java examples for java.util:BitSet

Description

BitSet To Byte

Demo Code


//package com.java2s;
import java.util.BitSet;

public class Main {
    public static byte bitSetToByte(BitSet bitSet) {
        byte[] b = new byte[1];

        for (int i = 0; i < bitSet.length(); i++) {
            if (bitSet.get(i))
                b[0] |= 1 << i;/*from   w w  w . j  a  v a  2  s  . c om*/
        }
        return b[0];
    }
}

Related Tutorials