/* * To change this template, choose Tools | Templates * and open the template in the editor. */packagelzw;importjava.io.*;publicclasslzw1{publicstaticvoidmain(String[]args)throwsFileNotFoundException{FileInputStreaminput=newFileInputStream(newFile("c:\\grande2.txt"))FileOutputStreamoutput=null;if(args[0]==""){System.out.println("Usage: java lzw <filename>");System.exit(1);}try{input=newFileInputStream(args[0]);}catch(FileNotFoundExceptionfnfe){System.out.println("Unable to open input file: "+args[0]);System.exit(1);}try{output=newFileOutputStream("compressed.lzw");}catch(FileNotFoundExceptionfnfe){System.out.println("Unable to open output file compressed.lzw ");System.exit(1);}LZWCompressionlzw=newLZWCompression(input,output);lzw.compress();/* compress the file */try{input.close();output.close();}catch(IOExceptionioe){System.out.println("IOException in main().");System.exit(1);}System.out.println("Done! Compressed file: compressed.lzw");}}