java多个文件压缩下载
public static void zipFiles(File[] srcfile,ServletOutputStream sos){ byte[] buf=new byte[1024]; try { //ZipOutputStream类:完成文件或文件夹的压缩 ZipOutputStream out=new ZipOutputStream(sos); for(int i=0;i<srcfile.length;i++){ FileInputStream in=new FileInputStream(srcfile[i]); out.putNextEntry(new ZipEntry(srcfile[i].getName())); int len; while((len=in.read(buf))>0){ out.write(buf,0,len); } out.closeEntry(); in.close(); } out.close(); System.out.println("压缩完成."); } catch (Exception e) { e.printStackTrace(); } }