This project implements the Huffman coding algorithm to compress and decompress files of any type. While Huffman coding is efficient for many scenarios, it's important to note that it may occasionally increase the size of certain compressed files due to the nature of encoding.
The tool was developed using Java
and features a user-friendly graphical interface built with JavaFX
.
Unlike many other implementations, this project minimizes the use of strings, which are resource-intensive in terms of both memory and processing time, to improve its performance.
The header contains the following information:
- Original File Extension.
- Number of Padding Bits.
- Header Size (in bits).
- Huffman Tree Structure.
The Huffman tree is stored using the Standard Tree Format
(STF) in post-order traversal. Internal nodes are encoded as 0
, while leaf nodes are encoded as 1
followed by the byte value.
A Stack
is used to decode the tree format.
- If you encounter
1
, read the byte value, create a node, and push it onto the stack. - If you encounter
0
, pop two nodes (pop right and pop left), create a parent node, and push it back onto the stack. - The stack's final node is the root of the Huffman tree.
- Friendly User Interface: Easy-to-navigate GUI for seamless interaction.
- Compression Statistics: Provides insights about compression efficiency.
- Accurate Decompression: Ensures files are restored to their original state.
- Efficient I/O Operations: Uses buffered reading and writing for performance optimization.
Click me to see the demo (⌐■_■)
This project was developed with the help of the following resources: