最近写了个小程序,把jar包解压缩后,修改里面的一个配置文件,然后再重新压缩。结果运行该jar包中的程序时,报找不到指定的类。我对比了一下重新压缩后的jar包里的每个类文件比原压缩包中小了一些。其他没发现什么异常,不知是什么原因重新压缩后会找不到类。
   我的压缩文件的部分程序如下:
static final int BUFFER=2048;
//filelist:  要压缩的文件列表
//filename:  压缩后文件名
public static boolean Compressfile(String[] filelist,String filename){


try {
// 创建ZipOutputStream对象,将向它传递希望写入文件的输出流
File zipFile=new File(filename);
FileOutputStream fos=new FileOutputStream(zipFile);
ZipOutputStream zout=new ZipOutputStream(new BufferedOutputStream(fos,BUFFER));


for(int i=0;i<filelist.length;i++)
//调用compress压缩文件
if(!(compress(filelist[i],zout))){
System.out.println("failed compress the file"+filelist[i]);
zout.close();
return false;

}   zout.close();
return true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}






}

private static boolean compress(String filename,ZipOutputStream zout){

File file=new File(filename);
byte[] buf=new byte[BUFFER];

try {

if(file.isDirectory()){ ZipEntry ze=new ZipEntry(filename+"\\");
zout.putNextEntry(ze);
zout.closeEntry();
String[] fl=file.list();
for(int i=0;i<fl.length;i++){
   StringBuffer sb=new StringBuffer(fl[i]);
    sb.insert(0,filename+"\\");
        fl[i]=sb.toString();
compress(fl[i],zout);
}

}else{ FileInputStream fin=new FileInputStream(filename);
BufferedInputStream in=new BufferedInputStream(fin); 
ZipEntry ze=new ZipEntry(filename);
zout.putNextEntry(ze);




while (true) 
{
int nRead = in.read(buf, 0, buf.length);
if (nRead <= 0)
break;
zout.write(buf, 0, nRead);

} zout.closeEntry();
}

return true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}



}
请问问题出在哪里呢?是否往ZipOutputStream中写文件时有问题呢?会写完以后的文件大小变小。哪位大侠帮忙指点一下,多谢了!