R
R
rbondarenko2018-03-03 00:24:49
Java
rbondarenko, 2018-03-03 00:24:49

Java. How to write and read bits of huffman code to a file?

I formed a huffman tree, calculated encodings for characters, translated it all into the form "001101010101011", stalled at the moment of writing these bits to a file. Here I found two classes for writing bits and reading, but my ones and zeros do not match when reading back. I do not write the code table to the file yet. Just tried to write bits to a file.
https://courses.cs.washington.edu/courses/cse143/1...
https://courses.cs.washington.edu/courses/cse143/1...
Please tell me how to implement this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Maznitsa, 2020-05-08
@raydac

you can use the JBBP library , then writing bit sequences will be reduced to a simple

JBBPOut.BeginBin(JBBPBitOrder.LSB0).Bits(JBBPBitNumber.BITS_3, 5).Bits(JBBPBitNumber.BITS_6,34).End().toByteArray();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question