what does byte[] do while unzipping file ?
This code gets the string contained in a zim file.
What does the byte[] buffer = new byte[1024]; do ? Why its size is 1024 ?
6 Replies
Hey, @tyranobast!
Please remember to
/close
this post once your question has been answered!*zip not zim
it reads given length of bytes from the inputstream
It's pretty much a buffer, to receive the bytes being extracted, before writing them back to the destination. Doing that one byte at a time would have a lot of overhead, so it's done using a buffer in the middle
It doesn't matter the size. It just needs to be "far more than 1, and not unrealistically gargantuan". Pick anything between 500 and 10000
It's 1024 because as it is close to a low-level concern, and there is this cargo cult that anything that can be described as such loves powers of 2
You don't have to handle that yourself. You could call the InputStream's readAllBytes() method.
It will do the same internally.
Okay thanks !
Post Closed
This post has been closed by <@428632258413330442>.