Here's another (more specific example) of how you could do it: (please note that I've used the IOUtils package. This is included in the Apache Commons library, which can be downloaded from: http://commons.apache.org/downloads/download_io.cgi It is also included in the default install of Mendix)
// BEGIN USER CODE
IMendixObject newFileDocument = Core.create(getContext(), "System.FileDocument");
zipFile(newFileDocument, files, getContext());
return true;
// END USER CODE
// BEGIN EXTRA CODE
private static void zipFile(IMendixObject destinationZipFile, List<system.proxies.FileDocument> filesToZip, IContext context)
throws IOException {
File tempFile = File.createTempFile("zipfile", "tmp");
ZipOutputStream zipfile = new ZipOutputStream(new FileOutputStream(tempFile));
for (FileDocument file : filesToZip) {
InputStream fileInputStream = Core.getFileDocumentContent(context, file.getMendixObject());
zipfile.putNextEntry(new ZipEntry(file.getName()));
IOUtils.copy(fileInputStream, zipfile);
fileInputStream.close();
}
zipfile.close();
InputStream zipInputStream = new FileInputStream(tempFile);
Core.storeFileDocumentContent(context, destinationZipFile, zipInputStream);
tempFile.delete();
}
// END EXTRA CODE
On this location you can find an example of how you can create a zip file. Just create an action in your modeler that collects all objects and writes some files in a temp folder. Than build your own action using the sample code from the link and add all the temp files to your zip.
Store the created zip in your object and you're done...
Based on this forum post I've created a complete module and added it to the Mendix appstore as "Zip File Document list" module