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

QuestionNice topic Pinmembersanya.fesak21-Sep-11 20:01 
Generallzw in matlab Pinmemberhana.rahmati30-Apr-10 23:14 
Questionalgorithm for n-queen Pinmemberhana.rahmati30-Apr-10 22:38 
GeneralI download your souce code and I have J creator and net beams install how do I run this file to test it PinmemberBulitpruf7-Aug-09 8:53 
GeneralRe: I download your souce code and I have J creator and net beams install how do I run this file to test it Pinmembermitesh355519-Jan-10 18:15 
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.
QuestionCan you also provide the decompression method Pinmemberpakhtoon18-Nov-07 13:43 
AnswerRe: Can you also provide the decompression method Pinmembermanishaswati30-Aug-08 4:26 
AnswerRe: Can you also provide the decompression method Pinmemberduraigowardhan1-Oct-09 6:05 
QuestionRe: Can you also provide the decompression method Pinmemberskumarmails17-Jan-10 23:47 
AnswerRe: Can you also provide the decompression method Pinmemberguyver.nihilith14-Feb-10 6:24 
QuestionTABLE_SIZE PinmemberGordonMorgan4-May-07 6:55 
Generalurgent Pinmembersimarjeet26-Apr-07 6:47 
GeneralRe: urgent PinmemberKusmadi Cakep8-Jan-10 21:35 
GeneralJ2ME for LZW Pinmemberfur12820-Mar-07 5:32 
GeneralRe: J2ME for LZW Pinmembered welch3-Jun-07 8:47 
GeneralLZW in VC++ Pinmembermannur28-Feb-07 5:27 
Generalrequest Pinmemberrancidbondut19-Feb-07 9:03 
GeneralRe: LZW for J2ME Pinmemberfahadkhowaja16-Feb-07 3:09 
Generallzw for j2me Pinmemberscntuan10-Sep-06 8:26 
GeneralCongratulations and to follow !!! PinmemberPipa_Soft15-Aug-06 6:41 
GeneralRe: Congratulations and to follow !!! Pinmemberpakhtoon18-Nov-07 13:47 
GeneralRe: Congratulations and to follow !!! Pinmemberskumarmails17-Jan-10 23:34 
Generallzw copyright Pinmembersnorkelman13-Aug-06 8:33 
GeneralRe: lzw copyright Pinmemberfahadkhowaja13-Aug-06 8:47 

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
Web01 | 2.8.150128.1 | Last Updated 13 Aug 2006
Article Copyright 2006 by fahadkhowaja
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid