You can't really. Remember, an int stores a (32-bit in Java?) value, and doesn't store anything else. A 'bitstring' is really a value and a length. You could represent it as a struct from C, or a small class with public variables in Java. Think of a bitstring as what you need to pass to FileBitWriter in order to get it write it, and the solution becomes apparent quickly.
For example, an int with 56 in it could be represented by any number of bitstrings, since we don't know how many bits are used to store it. It could be necessary to store it in 8 bits, or 9, or 10, etc etc.
You shouldn't have to bother with the 'bit-pushing' operations found in FileBitWriter. Just use the writeBits() method and you should be good.
On a side note, if you have some guarantee that the top 5 bits of an int will never be used for data, you could pack the length of a bitstring in the top 5 bits, but that probably won't work for what you want. |