FileOutputStream fos = new FileOutputStream(desFile);
JarOutputStream jos = new JarOutputStream(fos);
FileInputStream fis = new FileInputStream(file[i]);
JarEntry entry = new JarEntry(file[i].getName());
//这一行,打包之后用WINRAR打开,文件名称如果是中文,就会出现乱码
entry.setMethod(JarEntry.DEFLATED);
jos.putNextEntry(entry);
int n = fis.read(buffer);
while(n != -1)
{
desLen+=n;
jos.write(buffer,0,n);
n=fis.read(buffer);
}
jos.flush();
fis.close();