[求助]一个zip压缩的小程序,请大家指错!
程序很简单,但是不知道为什么输出的压缩文件里是0字节!!
请大家指教!
import java.io.*;
import java.util.zip.*;
class Zipper
{
public static void main(String args[])
{
try{
ZipOutputStream zip=new ZipOutputStream(new FileOutputStream("out.zip"));
zip.setComment("good");
zip.setMethod(ZipOutputStream.DEFLATED);
zip.setLevel(1);
ZipEntry entry=new ZipEntry("goodFile.txt");
zip.putNextEntry(entry);
byte cpact[]={6,9,4,5,6,64,6,6,98,3,6,64,6,64,64,64,76,4,5,46,64,1,36};
zip.write(cpact);
}catch (Exception e){System.out.println("Exception!");}
}
}