Questions tagged [zipinputstream]

A mechanism for reading zip-compressed data from a stream

A ZipInputStream is a mechanism for reading data from a stream, where the data is in a zip-compressed format. A stream is usually comprised of data being read from a local file, or data being transmitted from a remote server over a network protocol such as HTTP or FTP. As the data is read from the stream, the ZipInputStream decompresses it, and returns the uncompressed data to the application.

164 questions
35
votes
3 answers

getInputStream for a ZipEntry from ZipInputStream (without using the ZipFile class)

How can I get an InputStream for a ZipEntry from a ZipInputStream without using the ZipFile class?
Mohammad Hassany
  • 898
  • 1
  • 14
  • 30
34
votes
6 answers

How to speed up unzipping time in Java / Android?

Unzipping files on android seems to be dreadfully slow. At first I thought this was just the emulator but it appears to be the same on the phone. I've tried different compression levels, and eventually dropped down to storage mode but it still takes…
digitalWestie
  • 2,647
  • 6
  • 28
  • 45
20
votes
10 answers

Reading from a ZipInputStream into a ByteArrayOutputStream

I am trying to read a single file from a java.util.zip.ZipInputStream, and copy it into a java.io.ByteArrayOutputStream (so that I can then create a java.io.ByteArrayInputStream and hand that to a 3rd party library that will end up closing the…
pkaeding
  • 36,513
  • 30
  • 103
  • 141
18
votes
3 answers

Error "must not be null" in Kotlin

There are multiple files in a .zip file, which I'm trying to get. Trying to unzip the files provides a java.lang.IllegalStateException: zis.nextEntry must not be null. How to do it the right way? @Throws(IOException::class) fun unzip(zipFile:…
Petras Bartusis
  • 181
  • 1
  • 1
  • 3
17
votes
5 answers

How can I avoid mutable variables in Scala when using ZipInputStreams and ZipOutpuStreams?

I'm trying to read a zip file, check that it has some required files, and then write all valid files out to another zip file. The basic introduction to java.util.zip has a lot of Java-isms and I'd love to make my code more Scala-native.…
pr1001
  • 21,727
  • 17
  • 79
  • 125
10
votes
4 answers

Getting specific file from ZipInputStream

I can go through ZipInputStream, but before starting the iteration I want to get a specific file that I need during the iteration. How can I do that? ZipInputStream zin = new ZipInputStream(myInputStream) while ((entry = zin.getNextEntry()) !=…
Jils
  • 783
  • 5
  • 12
  • 32
9
votes
3 answers

java zipentry getsize returns -1

Java zipEntry.getSize() returns the size of the actual file and some times it returns -1 (though the file size is greater than 0). Java API document says "Returns the uncompressed size of the entry data, or -1 if not known." Not sure on what…
yottabrain
  • 2,387
  • 5
  • 23
  • 37
9
votes
2 answers

How to create compressed Zip archive using ZipOutputStream so that method getSize() of ZipEntry returns correct size?

Consider the code example that put a single file test_file.pdf into zip archive test.zip and then read this archive: import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; public…
user1569844
9
votes
4 answers

Java create InputStream from ZipInputStream entry

I would like to write a method that read several XML files inside a ZIP, from a single InputStream. The method would open a ZipInputStream, and on each xml file, get the corresponding InputStream, and give it to my XML parser. Here is the skeleton…
Tim Autin
  • 6,043
  • 5
  • 46
  • 76
9
votes
2 answers

How to create ZIP files using list of Input streams?

In my case I have to download images from the resources folder in my web app. Right now I am using the following code to download images through URL. url = new URL(properties.getOesServerURL() + "//resources//WebFiles//images//" +…
Avyaan
  • 1,285
  • 6
  • 20
  • 47
7
votes
3 answers

Read ZipInputStream in Kotlin

I am trying to read a zipped file using Kotlin and ZipInputStream into a ByteArrayOutputStream() val f = File("/path/to/zip/myFile.zip") val zis = ZipInputStream(FileInputStream(f)) //loop through all entries in the zipped file var entry =…
backcab
  • 638
  • 1
  • 6
  • 21
7
votes
1 answer

ZipInputStream(InputStream, Charset) decodes ZipEntry file name falsely

Java 7 is supposed to fix an old problem with unpacking zip archives with character sets other than UTF-8. This can be achieved by constructor ZipInputStream(InputStream, Charset). So far, so good. I can unpack a zip archive containing file names…
kriegaex
  • 63,017
  • 15
  • 111
  • 202
6
votes
2 answers

Java: Zipinputstream to Zipoutputstream leads to "end-of-central-directory signature not found" Error

I try to copy a Zip from a Zipinputstream to a Zipoutputstream. I store the Zip as byte[] in a Oracle database. I use Zipinputstream to decompress the zip (later I want to edit the Zip) and then put it into a Zipoutputstream to get a new byte[] and…
Sue
  • 73
  • 1
  • 4
6
votes
5 answers

How to reuse / reset an ZipInputStream?

I want to reset the ZipInputStream (ie back to the start position) in order to read certain files in order. How do I do that? I am so stucked... ZipEntry entry; ZipInputStream input = new…
JustToHelp
  • 87
  • 2
  • 10
6
votes
1 answer

Getting IOException Push back buffer is full while trying to unzip a String value using ZipInputStream

I am trying to unzip a String value. But I am getting a java.io.IOException: Push back buffer is full: public byte[] unzipArray(String stringToUnzip) { byte[] inputByteArray = Base64.decode(stringToUnzip); …
Radhika
  • 423
  • 7
  • 22
1
2 3
10 11