This repository contains a Java-based implementation of a file compression system utilizing Huffman encoding. Huffman encoding is a lossless data compression algorithm that is widely used for reducing the size of data files without any loss of information. You can also decompress the file using this app into its original form. This app also has some additional features such as: Given a string of alphabetic characters, you can compress the size of its bit sequence to obtain a binary sequence that has size significantly lesser than the original, this new sequence can then be sent through a network or saved in file so that it can be decompressed whenever required.
- Huffman Encoding: Implements Huffman Tree and Encoding algorithms to compress files efficiently.
- User Interface: A simple GUI (
EncoderGUI.java
) to interact with the system. - Custom Data Structures: Includes implementations of various data structures such as singly linked lists, priority queues, and more, tailored for the compression tasks.
- Progress Tracking: Visual progress bar to monitor the compression/decompression process.
The main code is contained inside src folder
ByteNode.java
: Represents a node containing byte information used in Huffman encoding.CharLinkedList.java
: A linked list implementation for storing characters, used in encoding.CharNode.java
: Represents a node containing character information used in Huffman encoding.Displayer.form
andDisplayer.java
: Handles the display functionalities of the GUI.EncoderGUI.java
: The main GUI for interacting with the compression system.HuffCompression.java
: Core logic for compressing and decompressing files using Huffman encoding.HuffmanEncoder.java
: Contains methods to generate Huffman codes and encode files.HuffmanTree.java
: Constructs the Huffman tree necessary for encoding.Message.java
: Handles messaging within the application.MinPriorityQueue.java
: Implementation of a priority queue, essential for Huffman tree construction.Node.java
: Basic node structure used in various data structures.ProgressBar.java
: Implements the progress bar feature in the GUI.QueueLL.java
: A queue implementation using linked lists.SinglyLinkedList.java
: Basic singly linked list implementation.ThreadedText.java
: Manages text in a multithreaded environment.
- Java Development Kit (JDK) 8 or higher.
- A Java IDE (e.g., IntelliJ IDEA, Eclipse) or any text editor with Java support.
-
Clone the repository to your local machine using:
git clone https://github.com/ammarlodhi255/file-compression-system.git
-
Navigate to the project directory:
cd file-compression-system/src
-
Open the project in your preferred Java IDE.
- Compile the project: Ensure all
.java
files are compiled. Most IDEs handle this automatically. - Run the GUI:
- Execute
EncoderGUI.java
to launch the user interface. - Use the provided options to compress or decompress files.
- Execute
- Command Line Interface (CLI):
- If you prefer a non-GUI approach, modify the
HuffCompression.java
to take input from the command line.
- If you prefer a non-GUI approach, modify the
-
Compress a text file:
- Open the GUI.
- Select the file you want to compress.
- Click on the "Compress" button and specify the destination for the compressed file.
-
Decompress a file:
- Open the GUI.
- Select the compressed file.
- Click on the "Decompress" button and choose where to save the decompressed file.
If you'd like to contribute to this project, please fork the repository and use a feature branch. Pull requests are warmly welcome.
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- Push to the branch.
- Submit a pull request.