Q:

Download zip-compressed folder of xml files from liferay portlet

I have a portlet, and using Spring MVC I want to download some dynamically created files.  I mean I have List of String 
List<String> xmls

,which contains the content of xml files, and I have some link in my view     
<portlet:resourceURL var="exportForms" id="exportForms" /> 

If user click this
<a href="${exportForms}">download</a>

then, resourceMapping function have to make xml files form list of string, and pack them into compressed zip files. 
@ResourceMapping("exportForms")
public void exportForms(ResourceRequest request, ResourceResponse response) {...}

And I do not know how can I do this.  I found, how to download one, simple file, but there is no solution, how to download compressed folder of files, dynamically created from list of string. 
regards

A:

Assuming Liferay 6.1
imports
import java.io. File;
import com.liferay.portal.kernel.util. FileUtil;
import com.liferay.portal.kernel.zip. ZipWriter;
import com.liferay.portal.kernel.zip. ZipWriterFactoryUtil;

And your resource method should look something like
    response.setProperty("Content-Disposition", "attachment; filename=myarchive.zip");
    response.setContentType("application/zip");

    final ZipWriter writer = ZipWriterFactoryUtil.getZipWriter();

    for (String filename : xmls) {
        byte[] file = FileUtil.getBytes(new File("filename"));
        writer.addEntry(filename, file);
    }

    byte[] archive = writer.finish();
    response.getPortletOutputStream().write(archive);

