java – How to compress and download multiple files at once with PrimeFaces StreamedContent

I want to compress several files and download them in one. However, I have not found a way to do it. Can any one give me a light? My current code is like this (only works for one file, but I wanted to get a list, zip it to download it):

pkgGenerateSourceController.java

                public StreamedContent getDownloadContent () throws IOException {
if (downloadContent == null) {
generateJavaSource ();

downloadContent = new DefaultStreamedContent (
generationResult.getSourceCode (). getByteSource (). openBufferedStream (),
"text / plain",
generationResult.getSourceCode (). getFileName (),
StandardCharsets.UTF_8.name (),
(int) generationResult.getSourceCode (). getByteSource (). size ()
)
}

return downloadContent;
}

generate-source.xhtml