zip4j
zip4j copied to clipboard
zip files with stream
Hi,
I have look at the example here https://github.com/srikanth-lingala/zip4j#adding-entries-with-zipoutputstream Where we are zipping file using stream, but it was doing password protected each file instead of the zip file itself?
Here is the sample code
ainfo has filename and byte []
final ZipParameters zipParameters = createZipParameters(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ZipOutputStream zos = new ZipOutputStream(bos, password.toCharArray());
for (AttachmentInfo ainfo : attachments) {
zipParameters.setFileNameInZip(ainfo.getName());
zos.putNextEntry(zipParameters);
zos.write(ainfo.getAttachment());
zos.closeEntry();
}
zos.close();
bos.close();
return bos.toByteArray();
How I can just put password on zip file not on each file?