zip4j icon indicating copy to clipboard operation
zip4j copied to clipboard

zip files with stream

Open pardeep131085 opened this issue 3 years ago • 0 comments

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?

pardeep131085 avatar Aug 09 '22 13:08 pardeep131085