A small implementation of Huffman encoding and decoding in Java
The below screenshot shows the GUI for the Encoder.
- Select the file you want to compress by clicking "Open File".
- Once the file is loaded, you will see a lable mentioning the name of the file on the right
- Now click "Encode" button which will encode the file in the directory that file belongs to.
- Once encoded, you can see the original file size, compressed file size and compression percentage statistics. You can also view the character frequency map on the left side and the encoded messages for each character on the right side.
The encoding process creates three files named
- "encoded.txt" - The compression version of the original file. (The compressed file is automatically named "encoded.txt")
- "tree.txt" - A supporting file needed for decompression, which consists of serialized object with information regarding character to codeword map
- "char.txt" - A helper file containing the character frequency map (the map shown on the left side in the above picture)
All the above files are stored using BitSet, hence they may not be in a human readable format.
The below screenshot shows the GUI for the Decoder.
- Select the file called "encoded.txt" that you would have obtained from the encoding process.
- Once the file is selected, name your output file.
- Now click "Decode" button which will prompt saying that the file is restored and will show it's original size.
The decoding process needs two other supporting files ("char.txt", "tree.txt") which would have been created as by products during the encoding process.
- Use an adaptive huffman technique
- Allow the user to specify the name of the output file that would be generated after encoding step
- Add feature for compression of multiple files