我可以知道如何随机访问zip文件并解压缩ZipEntry吗?
基本上我已经知道了我希望从zip文件中获取的文件,并且不希望将其解压缩。
答案 0 :(得分:1)
以下是将zip条目作为流获取的示例(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);