I am practicing the huffman encoding from my programming class. I have done the almost all the encoding part. For example, I have assigned each character a code (i.e. a=100100) and convert each char in the text according to it's code. Then I parse each code into a List of Byte, like parsing 100100 into a Byte and store it into the List. However, I need to write all the Bytes into a .txt file. I realized there is a problem.
Example: one character has the code "1001" and it will be written into the .txt file as 1 byte instead of just 4 bits.
I know that after huffman encoding, characters are stored in a format like: "11100111101011111101011011111000010000101" but now my situation is each character take 1 byte of size, which has no different in size with the original input file before encoding.
Is there any way to store the code in the format like "11100111101011111101011011111000010000101"?
Sorry for my English, I tried my best to explain my confusion.