Here is a Huffman code program in 6 files, coded in Java.
The program either reads a file directly from standard input,
or if the file name is on the command line, it uses that as the input.
The program analyzes input file to
get the symbol frequencies, and then calculates the code words
for each symbol. It also actually creates the output
coded file. However this file is a string of 0
and 1ascii characters, not binary numbers.
To actually produce a binary file would require
more code. The code here does not create and transmit the
decoding tree or information needed to create the decoding tree
such as the frequency table.

The encode algorithm (function encode inside
Huffman.java) just uses sequential search, although
the corresponding decode algorithm makes efficient use of the Huffman tree.
The priority queue (implemented in the file PQueue.java)
just uses a simple list and sequential search, whereas a good priority
queue should be implemented with a heap.

With the listing below I am experimenting
with a program to color code the Java listing:
Java source.