Converts a BitSet to String - Java java.util

Java examples for java.util:BitSet

Description

Converts a BitSet to String

Demo Code


//package com.java2s;

import java.util.BitSet;

public class Main {
    /**//from w w  w.j  a va2s . c  o m
     * Converts a BitSet to String
     * @param bits
     * @param length
     * @return 
     */
    public static String bitSetToString(BitSet bits, int length) {
        String sbits = "";
        for (int i = length - 1; i >= 0; i--)
            sbits += (bits.get(i) ? "1" : "0");

        return sbits;
    }
}

Related Tutorials