File zipFile = IOUtil.createTempFile("zip"); ZipOutputStream zipout = new ZipOutputStream(new FileOutputStream(zipFile)); FileInputStream fileIn; byte[] bffer = new byte[2048]; for (Map<String, String> result : results) { file = new File(result.get("path")); ZipEntry firstEntry = new ZipEntry(result.get("name")); zipout.putNextEntry(firstEntry); zipout.setEncoding("gb2312"); fileIn = new FileInputStream(file); int outSize = fileIn.read(bffer); while (outSize > 0) { zipout.write(bffer, 0, outSize); outSize = fileIn.read(bffer); } fileIn.close(); zipout.flush(); IOUtil.deleteFile(file); } zipout.close();
只是记录一下,代码严重不全