Click here to Skip to main content
Click here to Skip to main content

LZW Compression Algorithm Implemented in Java

, 13 Aug 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
This article provides an implementation of the LZW compression algorithm in Java


I recently had the opportunity to look into compression for a project. I had to implement the Lempel-Ziv-Welch (LZW) algorithm for mobile phones in J2ME but before that, I implemented it in Java for testing purposes.

I wish to thank Mark Nelson for pointing out that the Unisys patent on this algorithm has expired, so there are fewer headaches in the use of this algorithm.


This implementation is actually based on the C version of the implementation by Mark Nelson at Please refer to this website for further details about the algorithm. The Java adaptation is designed to work for ASCII encoded text files.


  • 13th August, 2006: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Singapore Singapore
No Biography provided

Comments and Discussions

Generalhelp me to implementing the "dynamic markov compression of C version" to Java (JSDK) and J2me version.. :( Pinmemberbytescode28-Apr-09 2:39 
Dear all,
I've a final project of my college about implementing DMC (Dynamic Markov Compression) algorithm using Java (JSDk) and java J2me.
I've found the source of this algorithm (DMC), but it write using C version : --> I've using this, but it's more complex Frown | :( But when I'm trying it, it run well and give the good result. --> I haven't try it. It contain only C file and I don't know how to do that... Frown | :(
And, I'm try to "translate" DMC of C version (according example of, but it only run well at compression. It failed when decompression Frown | :(
But, I thinks, both of compression and decompression (of my script- DMC Java version-) is wrong. I judge that because when I'm compare the ouptput text file of DMC (C version) and dmc (java version), each of output text file contain the different character (Theory said that if it same algorithm, it must be the same output and also the same character in it) Frown | :(
If you want to know my source 9and also help me to solve this problem), the URL is :
help me please. Thanks.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150123.1 | Last Updated 13 Aug 2006
Article Copyright 2006 by fahadkhowaja
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid