java 从在内存中创建ZIP文件,java内存创建zip,private stat
分享于 点击 22614 次 点评:143
java 从在内存中创建ZIP文件,java内存创建zip,private stat
private static byte[] createZip(Map files) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zipfile = new ZipOutputStream(bos); Iterator i = files.keySet().iterator(); String fileName = null; ZipEntry zipentry = null; while (i.hasNext()) { fileName = (String) i.next(); zipentry = new ZipEntry(fileName); zipfile.putNextEntry(zipentry); zipfile.write((byte[]) files.get(fileName)); } zipfile.close(); return bos.toByteArray(); }
用户点评