\r
characters that occur as new lines in some text-editors. Avoid such characters by making sure to right-click the input text files when you save them, rather than doing select-all, copy-paste into your editor.
DEBUG
flag to true
. Then re-compress the file. Now it will actually write out the file as ASCII bytes instead of bits (example: input, output), so you can read and debug it. Or set your BitIn/OutputStream to full-byte mode by calling .setBitMode(false)
on it.
InputStream
. You do want the output stream to be a BitOutputStream
, because you want to write the data as Huffman-compressed bits, one bit at a time.
There is a similar setup in the decompress method. In that method, the input is a BitInputStream
, because you're reading back in from a Huffman-compressed file, so you want to do that one bit at a time. But you're writing to a normal uncompressed ASCII file, so you are given just a normal OutputStream
for that.