I have the contents of a zip file in a byte array. The file contains a number of entries (typically about 12), but I only care about three of them.
I would like to somehow get this into a ZipFile
object, so I can pull those specific three ZipEntry
s out using ZipFile.getEntry
. I'm open to using something other than ZipFile
that has a similar look-up-by-name method like getEntry
.
My initial investigation suggests that I'm out of luck. ZipFile
requires a real file in the file subsystem (which I cannot and do not want to access) and so I can't get there from here, and no means other than ZipFile
exists that allows extracting particular entries by name; but I wanted to check. In languages like C# and Python, this is pretty straightforward (in C# I go from byte array to MemoryStream
to ZipArchive
; in Python I just wrap it in StringIO
and treat like a file), so I wanted to make sure I'm not missing something obvious.
My Plan B is to use ZipInputStream
and repeated calls to getNextEntry
to go through all dozen or so entries, and throw away all except the three I care about, but that just smells bad to me.