-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: ZipInputStream should properly implement available()
#311
Comments
When usiing ZipInputStream, it is unfortunately not possible to calculate the available bytes in the stream. It is because you have to read the complete zip file to know the exact available size which defeats the purpose of available. The reason you have to read through the complete file is you need to know the compressed sizes of each of the entry, and this information is stored in the headers which start before the entry itself. So, to know the number of bytes remaining in the stream, you need to first know the total amount of bytes you have in the stream, and this cannot be known, as explained above, unless you first read through the complete stream. It is for this purpose as well that JDK's ZipInputStream either returns a 0 or a 1. I will probably also add something similar to zip4j's inputstream instead of returning 0 in each case. |
Yes, I'm aware of that. That's why I suggested to implement the |
Oops. Sorry for that :-) I read the headline, and started thinking about a solution for it without reading your message completely. I will add your suggestion in the next release. |
Amazing! Looking forward to it 🎉
…On Thu, Apr 29, 2021, 7:08 PM Srikanth Reddy Lingala < ***@***.***> wrote:
Oops. Sorry for that :-) I read the headline, and started thinking about a
solution for it without reading your message completely.
I will add your suggestion in the next release.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#311 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHWE7C5QMLHDZLNJ2ZT4XTTLGHA3ANCNFSM43KFE3UA>
.
|
Feature added in v2.8.0 released today. |
The https://github.com/srikanth-lingala/zip4j/blob/master/src/main/java/net/lingala/zip4j/io/inputstream/ZipInputStream.java should properly implement the
InputStream::available()
method preferably with the same behavior as https://docs.oracle.com/javase/7/docs/api/java/util/zip/ZipInputStream.html#available()In the meanwhile, do you have a workaround for that?
The text was updated successfully, but these errors were encountered: