获取 ZipInputStream 的大小 [英] Getting the size of ZipInputStream

查看:32
本文介绍了获取 ZipInputStream 的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们完全读取流之前,有没有办法找到/估计 ZipInputStream 的大小?

Is there anyway to find/estimate the size of ZipInputStream before we completely read the stream?

例如,在读取用户数据之前,我们可以使用 getNextEntry 获取条目的元数据.

For instance, we can get the entry's metadata with getNextEntry before we can read the userdata.

Inputstream 有一个方法 available() 来返回可以从此输入流读取的字节数的估计值,但我找不到 ZipInputStream 的类似方法.

Inputstream has a method available() to return an estimate of the number of bytes that can be read from this input stream but I am not able to find a similar method for ZipInputStream.

推荐答案

如果你只有流,那我不这么认为.

If you have just the stream, then I don't think so.

zip 文件格式只有一个条目序列,然后是一个全局目录(其中包含所有文件及其大小的表格)在末尾.因此,如果无法访问该文件,您将无法获得该信息.

The zip file format has just a sequence of entries, and then a global directory (which has a table of all files and their sizes) at the end. So without access to the file, you won't get to that information.

这篇关于获取 ZipInputStream 的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆