Java BitSet to String bitSetToString(BitSet bits, int length)

Here you can find the source of bitSetToString(BitSet bits, int length)

Description

Converts a BitSet to String

License

Open Source License

Parameter

Parameter Description
bits a parameter
length a parameter

Declaration

public static String bitSetToString(BitSet bits, int length) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.BitSet;

public class Main {
    /**//from  w ww . j ava 2s  . co  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

  1. bitSet2String(BitSet b)
  2. bitSet2String(final BitSet bs)
  3. bitsetToString(BitSet bitset, int width, int height)
  4. bitsetToString(BitSet bs)