Reputation: 1155
May I know how I can randomly access a zip file and decompress an ZipEntry?
Basically I already know the files I wish to get from the zip file and do not wish to unzip it.
Upvotes: 0
Views: 1388
Reputation: 18458
Here is an example of getting the zip entry as a stream (ZipFile.getInputStream(entry));
ZipEntry entry = zipFile.getEntry(entryName);
InputStream xmlInStream = zipFile.getInputStream(entry);
//process the stream- below one is for xml parsing.
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
return documentBuilder.parse(xmlInStream);
Upvotes: 1