【问题标题】:Random access zip file using java.util.zip使用 java.util.zip 随机访问 zip 文件
【发布时间】:2013-08-07 10:20:22
【问题描述】:

我可以知道如何随机访问 zip 文件并解压缩 ZipEntry 吗?

基本上我已经知道我希望从 zip 文件中获取的文件并且不想解压缩它。

【问题讨论】:

    标签: java zip


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 1970-01-01
      • 2012-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多