We are now using NIO's Zip File System Provider to dynamically add meta file to difference zip file before send it to our user. The problem is we must make a copy of the original file, then add meta file to it, then delete the temp file after the task done. I feel that doing that task is very inefficient. I tried use NIO's MappedByteBuffer to directly map zip file to memory then manipulate it with Zip Input/Output Stream, but it is incredibly slow because there are too much zip entries and we doesn't need all.
I'm thinking of an In-memory Zip File System, which we can first load the zip file into memory, then manipulate it with without makes the stupid temporary copy and then delete it. But I can't find anything like that.
Can you share your experience and solution for this problem? Thank you very much!
Here is my effort with ZIP Input/Output Stream. The test.zip size is ~60MB, contains 1,142 files, 46 folders. Note that this is just a code snippet. Actually the byte byteBlock = "Hello World".getBytes() will be generated based on user's request.