import java.util.BitSet; public class Hello {
// reimplementation of BitSet.valueOf() for GCJ private static BitSet BitSet_valueOf(byte[] byteArray){ BitSet bitset = new BitSet(); int bit_index=0; for (byte b : byteArray ) { for ( int mask = 0x01; mask != 0x100; mask <<= 1 ) { boolean value = ( b & mask ) != 0; bitset.set(bit_index, value); bit_index++; } } return bitset; } public static void main(String args[]) { // BitSet.valueOf() is missing in GCJ //System.out.println("BitSet: "+BitSet.valueOf(new byte[]{ 3, 10, 8, 25 })); // not using this // format is little endian, prints indices where bitset.get(index)=true System.out.println("BitSet: "+BitSet_valueOf(new byte[]{ 3, 10, 8, 25 })); // using this } }