In my application I have to send XLS reports by email, but if the file is larger than 10 MB I have to split this file into multipart ZIP-s and send as a separate emails with attachments (one email - one ZIP part). If anyone knows library that will help me do it? Is there any easy way in Java?
Asked
Active
Viewed 4,149 times
1 Answers
2
Try Apache Commons Compress and Apache Commons IO.
You can create the zip like this (from the example documentation):
ZipArchiveEntry entry = new ZipArchiveEntry(name);
entry.setSize(size);
zipOutput.putNextEntry(entry);
zipOutput.write(contentOfEntry);
zipOutput.closeArchiveEntry();
You can pair this with FileUtils.readFileToByteArray( File file ); and then loop through the byte array writing out your zip files.

javamonkey79
- 17,443
- 36
- 114
- 172