|
import java.io.*;
public class lzw
{
public static void main ( String[] args )
{
FileInputStream input = null;
FileOutputStream output = null;
if( args[0] == "" )
{
System.out.println( "Usage: java lzw <filename>" );
System.exit( 1 );
}
try
{
input = new FileInputStream( args[0] );
}
catch ( FileNotFoundException fnfe )
{
System.out.println( "Unable to open input file: " + args[0] );
System.exit( 1 );
}
try
{
output = new FileOutputStream( "compressed.lzw" );
}
catch ( FileNotFoundException fnfe )
{
System.out.println( "Unable to open output file compressed.lzw " );
System.exit( 1 );
}
LZWCompression lzw = new LZWCompression( input, output );
lzw.compress(); /* compress the file */
try
{
input.close();
output.close();
}
catch ( IOException ioe )
{
System.out.println( "IOException in main()." );
System.exit(1);
}
System.out.println( "Done! Compressed file: compressed.lzw");
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.