class="java" name="code">public void createzip(){ List<File> nFileList = new ArrayList<File>(); nFileList.add(new File("C:\\Users\\Administrator\\Desktop\\测试移动到\\0001+国务院办公厅关于积极推进供应链创新与应用的指导意见.doc")); nFileList.add(new File("C:\\Users\\Administrator\\Desktop\\测试移动到\\0001+国务院办公厅关于积极推进供应链创新与应用的指导意见.pdf")); nFileList.add(new File("C:\\Users\\Administrator\\Desktop\\zenith.product.fms.main.js")); String strZipName = "C:\\Users\\Administrator\\Desktop\\lx.zip"; FileInputStream nFileInputStream = null; ZipOutputStream nZipOutputStream = null; try { nZipOutputStream = new ZipOutputStream(new FileOutputStream(strZipName)); for (File file : nFileList) { nFileInputStream = new FileInputStream(file); nZipOutputStream.putNextEntry(new ZipEntry(file.getName())); int len; while ((len = nFileInputStream.read()) != -1) { nZipOutputStream.write(len); nZipOutputStream.flush(); } } nZipOutputStream.close(); nFileInputStream.close(); System.out.println("生成lx.zip成功"); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }