我必须在内存中创建 ZIP 存档但是现在,我需要将它保存在磁盘中的真实 .zip 文件中。怎么做?伪代码:
public byte[] crtZipByteArray(ByteArrayInputStream data,ZipEntry entry) throws IOException{
ByteArrayOutputStream zipout = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(zipout);
byte[] buffer = new byte[1024];
int len;
zos.putNextEntry(entry);
while ((len = data.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
zos.closeEntry();
zos.close();
data.close();
return zipout.toByteArray();
}