1

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?

Przemek Nowak
  • 7,173
  • 3
  • 53
  • 57

1 Answers1

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