this is the first tool I created with Scala, it is also the first time I am dealing with text compression. But it was a lot of fun. This tool uses the LZW algorithm to compress text files for you.
Usage
Run:
For compression:
scala lzw.jar -c <filename> [<wordsize>]
For decompression:
scala lzw.jar -d <filename> [<wordsize>]
For version:
scala lzw.jar -v
Example:
scala lzw.jar -c input.txt 16
Example Output:
Compression done. Created output file input1.lzw size of the input file: 1257260 size of the compressed file: 539175 compression ratio: 57% Additional information:
A wordsize of 12 is usually good for small files, a wordsize of 16 or more for large files. The default wordsize used will be 14 bits.
The wordsize for decompression must be the same as you used for compression. Otherwise it won't work.
I made some tests that show the compression ratio for different wordsizes: