commons-compress-1.5.jar
//将byte数组,压缩为zip转为流输出
ZipArchiveOutputStream zos =(ZipArchiveOutputStream)new ArchiveStreamFactory().createArchiveOutputStream("zip", response.getOutputStream());
for (int i=0; i<fileList().size(); i++){
FileDTO item = dto.getFileList().get(i);
ZipArchiveEntry ze =new ZipArchiveEntry(item.getFileName());
zos.putArchiveEntry(ze);
//file
ByteArrayInputStream bais = new ByteArrayInputStream(item.getFileBytes());
IOUtils.copy(bais, zos);
bais.close();
}
zos.closeArchiveEntry();
zos.close();
//将byte数组,压缩为zip转为流输出
ZipArchiveOutputStream zos =(ZipArchiveOutputStream)new ArchiveStreamFactory().createArchiveOutputStream("zip", response.getOutputStream());
for (int i=0; i<fileList().size(); i++){
FileDTO item = dto.getFileList().get(i);
ZipArchiveEntry ze =new ZipArchiveEntry(item.getFileName());
zos.putArchiveEntry(ze);
//file
ByteArrayInputStream bais = new ByteArrayInputStream(item.getFileBytes());
IOUtils.copy(bais, zos);
bais.close();
}
zos.closeArchiveEntry();
zos.close();