to write the bits of a BitSet to a file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   zille_huma
Posted On:   Tuesday, April 24, 2001 11:46 PM

i am trying to build a compression tool. for that i am generating a code of bits for each character in the file to be compressed. i am using the BitSet class to generate a code. but now the problem is that i have to write this code to a file i.e. compressed file. how can i do that

Re: to write the bits of a BitSet to a file

Posted By:   Tim_Rohaly  
Posted On:   Wednesday, April 25, 2001 08:46 AM

Wow, that sounds enormously inefficient.
BitSet is really only meant for manipulating
a small number of bits as boolean values.
There is no way to get the value of more
than one bit at a time, and even with the one
bit you only get a boolean.


I suggest if you want to use a bit-set-like functionality,
you write your own class to do it. Bit manipulation in
Java is straightforward using shifts, bit masks, bitwise
ands and ors, etc. And it will be much more efficient
that using BitSet for this purpose.


Also, I suggest you make your compression classes
follow the examples set by java.util.jar and
java.util.zip, that way their usage is consistent
with the existing Java classes. (Check the source code
for those package to see how Sun does it!).

About | Sitemap | Contact