zip4j ZipFile getInputStream 总是 returns 大小为 1 的字节数组

zip4j ZipFile getInputStream always returns byte array with size 1

以下代码总是生成大小为 1 的字节数组,有什么想法吗?

FileHeader fh = (FileHeader) packageFile.getFileHeaders().get(1);
InputStream inputStream = packageFile.getInputStream(fh);
byte[] bytes=new byte[inputStream.available()];

zip 文件没问题!

你期待什么?也许您对 available() 的理解不正确。 returns 方法 估计 但取决于实现。

来自文档;

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

您似乎正在定义缓冲区 bytes 以将数据读入。