Example usage for java.util BitSet valueOf

List of usage examples for java.util BitSet valueOf

Introduction

In this page you can find the example usage for java.util BitSet valueOf.

Prototype

public static BitSet valueOf(ByteBuffer bb) 

Source Link

Document

Returns a new bit set containing all the bits in the given byte buffer between its position and limit.

Usage

From source file:Main.java

public static void main(String[] args) {

    BitSet bitset1 = BitSet.valueOf(new byte[] { 1, 2, 3 });

    // print the sets
    System.out.println("Bitset1:" + bitset1);

}

From source file:Main.java

public static void main(String[] args) {

    BitSet bitset1 = BitSet.valueOf(new long[] { 1L, 2L, 3L });

    // print the sets
    System.out.println("Bitset1:" + bitset1);

}

From source file:Test.java

public static void main(String[] args) {
    BitSet bitSet = new BitSet();
    long[] array = { 1, 2, 3 };
    bitSet = BitSet.valueOf(array);
    System.out.println(bitSet);//from w w  w  . ja  va  2 s.  c  o m

    long[] tmp = bitSet.toLongArray();
    for (long number : tmp) {
        System.out.println(number);
    }

    System.out.println(bitSet.previousSetBit(1));
    System.out.println(bitSet.previousClearBit(66));

}

From source file:Main.java

public static void main(String[] args) {

    ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[] { 1, 2, 3 });
    BitSet bitset1 = BitSet.valueOf(byteBuffer);

    // print the sets
    System.out.println("Bitset1:" + bitset1);

}

From source file:Main.java

public static void main(String[] args) {

    LongBuffer byteBuffer = LongBuffer.wrap(new long[] { 1L, 2L, 3L });
    BitSet bitset1 = BitSet.valueOf(byteBuffer);

    // print the sets
    System.out.println("Bitset1:" + bitset1);

}

From source file:de.upb.wdqa.wdvd.revisiontags.TagDownloaderRevisionData.java

/**
 * Converts a memory efficient byte[] representation to a more user friendly
 * List of Strings//from w w w . j a  va2  s  .  c o m
 */
private Set<DbTag> bytesToTags(byte[] bytes) {
    Set<DbTag> result = new HashSet<DbTag>();
    BitSet bitSet = BitSet.valueOf(bytes);

    for (int i = bitSet.nextSetBit(0); i > -1; i = bitSet.nextSetBit(i + 1)) {
        result.add(tagFactory.getTagById(i));
    }
    return result;
}

From source file:org.osgp.adapter.protocol.dlms.domain.commands.ConfigurationObjectHelperService.java

/**
 * Create a list of unique configuration flag type objects representing the
 * active bits in the register value./*www . ja  v  a2s .co  m*/
 *
 * @param flagByteArray
 *            The byte array holding the flag bits.
 * @return List of active configuration flag type objects.
 */
public List<ConfigurationFlag> toConfigurationFlags(final byte[] flagByteArray) {
    final List<ConfigurationFlag> configurationFlags = new ArrayList<>();
    final BitSet bitSet = BitSet
            .valueOf(new long[] { ((flagByteArray[0] & 0xFF) << 8) + (flagByteArray[1] & 0xFF) });
    for (int i = bitSet.nextSetBit(0); i >= 0; i = bitSet.nextSetBit(i + 1)) {
        final ConfigurationFlagType configurationFlagType = CONFIGURATION_FLAG_TYPE_PER_BIT_INDEX.get(i);
        configurationFlags.add(new ConfigurationFlag(configurationFlagType, true));
    }
    return configurationFlags;
}

From source file:com.roche.sequencing.bioinformatics.common.utils.BitSetUtil.java

public static BitSet readBitSetFromInputStream(InputStream inputStream) throws IOException {
    byte[] byteArray = IOUtils.toByteArray(inputStream);
    BitSet bitset = BitSet.valueOf(byteArray);
    return bitset;
}

From source file:bits.BinaryMessage.java

public BinaryMessage(byte[] data) {
    this(BitSet.valueOf(data), data.length * 8);
}

From source file:de.uniba.wiai.lspi.chord.data.ID.java

private static BitSet hashString(final String s) {
    return BitSet.valueOf(DigestUtils.sha1(s));
}