This repository contains a Java desktop application that implements Huffman coding for file compression and decompression. The project is a Swing-based utility that calculates byte frequencies, builds a Huffman tree, and exposes compression statistics in a graphical interface.
The implementation is intentionally simple and direct: it keeps the Java classes in the default package, so they can be compiled directly from the repository root without requiring a custom package structure.
Compressor demo; Tree and Compression information.
The application is focused on demonstrating the Huffman algorithm and information-theory metrics. In the current codebase, the main features are:
- File compression using Huffman coding
- File decompression from the internal compressed format
- Calculation of symbol frequencies and code assignments
- Display of Huffman tree information in the GUI
- Metrics such as entropy, average code length, efficiency, and elapsed time
- A Swing interface for selecting files and operating on them interactively
At the root of the project you will find the Java sources and the ready-to-run executables:
Huffman.java— application entry pointVista.java— Swing interface and user actionsControlador.java— controller that coordinates the model and the data structuresModelo.java— compression and decompression logic, code generation, and statisticsEstructura.java— tree structure and readers/writers used by the algorithmBinaryHeap.java— priority queue used in the Huffman constructionSimbolo.java— symbol representation used by the GUIResultadoCompresion.java— result model for compression statisticsProgressCallback.java— progress callback interfaceWinHuff_jar.jar— Java executable packageWinHuff_x86_x64.exe— Windows executablequijote.txt,quijote.huff,quijote_dec.txt— sample files for testing and demonstration
The flow implemented in the code is:
- Select a file from the user interface.
- Count the frequency of each byte value.
- Build a Huffman tree using the available priority queue structure.
- Generate prefix codes for each symbol.
- Write the compressed file together with the metadata required to reconstruct it.
- Read the compressed file back and recover the original bytes and extension.
- Show the resulting statistics in the interface.
The current implementation calculates and exposes:
- Entropy
- Average code length
- Relative efficiency
- Compression time
- Huffman tree visualization
Because the classes are in the default package, compile the project from the repository root:
javac *.java
java HuffmanThis launches the GUI window where you can choose a file and compress or decompress it.
The repository already includes user-facing executables at the project root so they can be used directly without recompiling:
WinHuff_jar.jarWinHuff_x86_x64.exe
These files are intended as the distribution artifacts for users who want to run the application without building it from source.
The Java sources are currently located at the repository root so the project remains compatible with the default-package build used by the current code. This is a practical choice for this repository and keeps the project easy to run and study.
The repository description indicates that the project is proprietary and the code is distributed under a copyright notice included in the original README. Please respect the original licensing and terms of use before reusing the code.
The repository includes sample files that can be used to test the compressor and observe its output:
quijote.txt— original sample textquijote.huff— a compressed sample generated by the applicationquijote_dec.txt— decompressed result for comparison
This project is best understood as a compact educational and demonstrative Huffman coding implementation rather than a general-purpose production compression library.

