Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39086

Re: reading zip file

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: reading zip file
Date 2019-08-08 11:30 -0400
Organization Aioe.org NNTP Server
Message-ID <qihf6i$2me$1@gioia.aioe.org> (permalink)
References <daa1fc10-39a1-4942-b9da-d7f5e1fa9907@googlegroups.com> <qihcn4$1mo7$1@gioia.aioe.org> <96b45a37-1ae3-49ea-b1ce-d35865af56a4@googlegroups.com>

Show all headers | View raw


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



Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

reading zip file Eric Douglas <e.d.programmer@gmail.com> - 2019-08-08 07:12 -0700
  Re: reading zip file Arne Vajhøj <arne@vajhoej.dk> - 2019-08-08 10:48 -0400
    Re: reading zip file Eric Douglas <e.d.programmer@gmail.com> - 2019-08-08 08:00 -0700
      Re: reading zip file Arne Vajhøj <arne@vajhoej.dk> - 2019-08-08 11:30 -0400
        Re: reading zip file Eric Douglas <e.d.programmer@gmail.com> - 2019-08-08 08:42 -0700
          Re: reading zip file Andreas Leitgeb <avl@logic.at> - 2019-08-08 17:51 +0000
          Re: reading zip file Arne Vajhøj <arne@vajhoej.dk> - 2019-08-08 17:17 -0400
      Re: reading zip file Joerg Meier <joergmmeier@arcor.de> - 2019-08-08 22:06 +0200
        Re: reading zip file Eric Douglas <e.d.programmer@gmail.com> - 2019-08-08 13:49 -0700
  Re: reading zip file Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-08-08 19:49 +0200
    Re: reading zip file Eric Douglas <e.d.programmer@gmail.com> - 2019-08-08 12:58 -0700
      Re: reading zip file Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-08-08 22:38 +0200

csiph-web