Hi Mark,
Below r my codes can u tell where I should add Deflater class with specified level I know we can set the level from 0-9 for best compression I want to use level "9".Can u plz help me.Iam trying this coz i want to compress my files during uploading.
import java.io.*;
import java.util.zip.*;
public class zipper1 {
public static final void main(
String [] args){
try {
File myDir=File("c:\\html");
ZipOutputStream outStream = new ZipOutputStream (new FileOutputStream("c:\\html\\out.zip"));
outStream.setMethod(ZipOutputStream.DEFLATED);
processFile(myDir, "SPLASH.gif",outStream);
outStream.close();
}
catch(Exception e){
e.printStackTrace();
}
}
static void processFile(File myDir, String fileName, ZipOutputStream out)
{
try
{
File f = new File(myDir, fileName);
FileInputStream in = new FileInputStream(f);
// Add ZIP entry to output stream.
ZipEntry e1 = new ZipEntry(fileName);
out.putNextEntry(e1);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0)
{
out.write(buf, 0, len);
}
out.closeEntry();
in.close();
}
catch (Exception e)
{
System.out.println("Error ::" + e);
}
}
}
Regards
Bikash
:roll: