Hi all friends,

I want to set the compression level in .zip file
creation.I know we can set compression level by using
java.util.zip.Deflator class and we can set level from
0-9 but Iam confused what will be the syntax for
that.If any one have any idea about this plz extend to
me.Below r my codes:-

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




__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to