A simple file compression tool implementing Huffman encoding for efficient file size reduction. This project provides an effective way to compress files, making them smaller while maintaining the integrity of the data.
- Huffman Encoding: Implements a well-known algorithm for lossless data compression.
- Java Documentation: Extensive JavaDocs are provided to make the code understandable for everyone.
- JUnit Testing: Comprehensive unit tests ensure the functionality and reliability of the code.
Huffman encoding is a method of lossless data compression. It assigns variable-length codes to input characters, with shorter codes assigned to more frequent characters. This minimizes the total number of bits needed to represent the data, leading to efficient compression.
- Count the frequency of each character in the input file.
- Build a binary tree using these frequencies.
- Generate binary codes for each character based on the tree structure.
- Write the compressed data to a new file.
For a detailed walkthrough of the process, check out the YouTube video where I demonstrate how to use the Huffman Encoder.
- Java Development Kit (JDK) 8 or higher
- Clone the repository:
git clone https://github.com/mrktsm/huffman-encoder.git
- Navigate into the directory:
cd HuffmanCoding
- Make sure huffmanzip.jar file is in the resources directory
To use the Huffman Encoder, run the following commands:
-To Encode a File:
java -jar resources/huffmanzip.jar -encode <filename>
-To Decode a File:
java -jar resources/huffmanzip.jar -decode <filename>
Replace with the name of the file you want to compress or decompress.
To run the unit tests, you can use JUnit. Ensure you have JUnit set up and run the test cases provided in the repository.
This project was developed for CS216 at Gettysburg College. Special thanks to my professor and peers for their support and guidance throughout the process.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.