On 8/8/2019 11:00 AM, Eric Douglas wrote:
> On Thursday, August 8, 2019 at 10:48:15 AM UTC-4, Arne Vajhøj wrote:
>> If the binary ZIP file is URL encoded then it is a big mess.
>>
>> If the binary zip file is present as binary data, then I think you can
>> change from:
>>
>> ZipInputStream zis = new ZipInputStream(new
>> ByteArrayInputStream(EntityUtils.toByteArray(entity)));
>>
>> to:
>>
>> ZipInputStream zis = new ZipInputStream(entity.getContent());
>>
>> (code simplified)
>
> I'm not sure what you mean by "is present as binary data".
Binary data 0x01 0x02 0x03 is 3 bytes - in URL encoding it would be
"%01%02%03" 9 bytes.
> I was wondering what the purpose of EntityUtils is there, if I could just use getContent().
>
> If it matters, I am reading the stream twice, once to check the total
> size of the zip files for a progress bar and once to extract them.
> Should this mean it's much more efficient to convert the HttpEntity
> to a byte[] array first? Should using getContent() as the input to
> the zip stream make the second read slower but use much less memory?
You will need to find it in the documentation or do a test.
But my guess is that getContent() will work the first time
and fail the second time.
Meaning that toByteArray may make sense if you really need that
progress bar.
Question: can't you just use HTTP content length instead??
Arne