试一下 我的 方法 这个 包你满意。。

public static void zip(File[] files, String outputFile) throws IOException
{
//如果files长度为0,zout.close()方法会抛异常: ZIP file must have at least one entry
if(files.length == 0)
{
LogUtils.warn("Log file list is empty");
return;
}
FileOutputStream out = null;
BufferedOutputStream buffOut = null;
ZipOutputStream zout = null;
try
{
out = new FileOutputStream(outputFile);
buffOut = new BufferedOutputStream(out);
zout = new ZipOutputStream(buffOut);
for (int i = 0; i < files.length; i++)
{
InputStream in = null;
BufferedInputStream buffIn = null;
try
{
in = new FileInputStream(files[i]);
buffIn = new BufferedInputStream(in, BUFF_SIZE);
ZipEntry zipEntry = new ZipEntry(files[i].getName());
zout.putNextEntry(zipEntry);
int len = 0;
byte data[] = new byte[BUFF_SIZE];
while ((len = buffIn.read(data)) != -1)
{
zout.write(data, 0, len);
}
}
finally
{
try
{
zout.closeEntry();
}
catch (IOException e)
{
LogUtils.exception(e, "Close zip file entry failed");
}
closeStream(buffIn);
closeStream(in);
}
}
}
finally
{
closeStream(zout);
closeStream(buffOut);
closeStream(out);
}
}