Problem: I need to download lot of files(size of file can be upto 2GB) and send those as zip to the client requesting for resource.
I was looking to parallelize that operation. Currently the library I've to use takes OutputStream
(in my case it's ZipOutputStream
) as input and write content of downloaded files to that output stream using ApacheCommons IOUtils
.
Problem with this approach is everything happens sequentially. I've to download one file and then write to OutputStream, create a new zipEntry, close that entry and then go next one.
I wanted to do the download operation in parallel and if possible I need write to ZipOutputStream
in parallel as well.
Anyone has faced this thing before?
I was planning to change signature of that library to return InputStream
of the downloaded resource so that I can get those content in parallel and then creating new ZipEntry for each of those stream in sequence. This way I would at least be able to download the file in parallel.
The way I'm creating ZipOutStream is as follows:
ZipOutputStream zo = new ZipOutputStream(httpservletResponse.getOutputStream);
Any thoughts?