Path: csiph.com!aioe.org!.POSTED.O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: reading zip file Date: Thu, 8 Aug 2019 10:48:05 -0400 Organization: Aioe.org NNTP Server Lines: 26 Message-ID: References: NNTP-Posting-Host: O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: csiph.com comp.lang.java.programmer:39084 On 8/8/2019 10:12 AM, Eric Douglas wrote: > I'm working on a new client-server application which requires saving client files to disk for every client that runs it. All files required by the client are in a zip file, hosted by a web service on a local domain server. > I'm writing the unzipped files to the client machine using this loop. > > ZipEntry zipEntry = null; > try (ByteArrayInputStream is = new ByteArrayInputStream(zipBytes); ZipInputStream zis = new ZipInputStream(is)) { > while ((zipEntry = zis.getNextEntry()) != null) { > > The zipBytes is a byte[] array generated from org.apache.http.util.EntityUtils.toByteArray(). The zip file is currently over 400 MB. I'm not sure how big this could potentially get. Do I have to get the entire zip file into memory before extracting? Should I be concerned how much memory this could require? Is there a better way? 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) Arne