BitSet To Char - Java java.util

Java examples for java.util:BitSet

Description

BitSet To Char

Demo Code


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

public class Main {
    public static char bitSetToChar(BitSet bitSet) {
        char result = 0;
        for (int i = 0; i < bitSet.length(); i++) {
            if (bitSet.get(i)) {
                result |= (1 << i);
            }//from ww  w . j a va  2 s.c  om
        }
        result &= Character.MAX_VALUE;
        return result;
    }
}

Related Tutorials