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
0
votes
0 answers

Do I need to close the GZIPInputStream when unpacking the gzip in a zip file?

sample code: import java.io.*; import java.util.zip.*; public class Main { public static void main(String[] args) throws IOException { try(FileInputStream fileInputStream = new FileInputStream("xxx.zip"); ZipInputStream…
Guo
  • 1,761
  • 2
  • 22
  • 45
0
votes
1 answer

How to solve ZipException: Invalid Block lengths when reading ZipInputStream with empty directory inside zip file (Java)

I am getting the error "ZipException: Invalid Block lengths" when reading a ZipInputStream from my java code. My zip file oppens and is extracted normally with my Zip file utility from windows, so it is not corrupted. The first entry inside the zip…
barduchi
  • 61
  • 1
  • 8
0
votes
1 answer

How to get bytes from ZipEntry without using ByteArrayOutputStream

Is there a way to make this a little simpler? Since I need the bytes of each entry is there any way to get them without using the ByteArrayOutputStream public UnzippedFile unzip(ZipFile zipFile) throws IOException { var unzippedFile = new…
BugsOverflow
  • 386
  • 3
  • 19
0
votes
1 answer

In Spring Boot Java Extracting the zip file from response without physically saving it

In Spring Boot the zip file that comes as a response has a corrupted structure before saving, but there is no problem when I save it physically. I need to take the file in the zip file and process the information in the database, but I cannot…
0
votes
0 answers

how to get the top level folder of a zip file using Java ZipInputStream?

I want to get the top level folder of a zip file using ZipInputStream. Say, I have a zip file test.zip that contains the following entries: topFolder/sub/sample.jpg When I use ZipInputStream, the first entry that it gets is topFolder/sub/ Is there a…
jetpack
  • 169
  • 1
  • 9
0
votes
2 answers

Extract a Single File From ZipInputStream

I have an ZipInputStream made from a byte array , I can iterate through the zipInputStream ZipEntrys but I cant find a method to get the data from the ZipEntry (ZipENtry.getExtras() is null on every entry) how would i go to extract all the files one…
Ftoy
  • 26
  • 6
0
votes
0 answers

Dynamically decide which java class to create instance of using yaml/json

I have an interesting problem in with one of my projects. I have ZipInputeStream from uploaded zip in spring boot application with several yaml file in it, which can have any name and dynamic content which we know and have java POJO objects for…
0
votes
1 answer

Java: How to efficiently process Zipfile reading and create byte[] using Multithreading and Async

I am currently developing a method in the Service layer implementation where the method receives a .zip file (file size could go up to 600~700MB) as a Multipart file. Out of all the files zipped in that Multipart file, there are only 4-5 JSON files…
0
votes
1 answer

Zip file containing more than one file is sent as string. How to read the string and extract individual files in Java?

Our external application sends the zip file name and content as two strings in the response to an API call. I converted the string to bytearray and used zipinputstream to read the bytearray. If the zip file contains only one file, I am able to read…
0
votes
0 answers

Is it faster to read a Zip file while unzipping it (in a stream) or wait for it complete unzipping and then read it?

I am currently reading a CSV file from a zip file. I have 2 options to read it. Read the CSV while it is being unzipped line by line by streaming it (ZipInputStream and openCSV) Unzip the entire CSV file first, and then go back and read the entire…
Kiran
  • 617
  • 6
  • 20
0
votes
2 answers

How to create Password protected GZIP java

I want to create password protected Gzip file in java. Is there any commons jar for that. I tried with GzipParameters, but there is no options for password. Thanks in advance.
user17723118
0
votes
2 answers

ZipInputStream is closes when reading first ZipEntry of Excel files

I'm uploading zip of excel files as multipart file, but when I create Workbook object of first file, the stream gets closed and I'm not able to read next files. its working with single file in zip but not with multiple files. can anybody help? TIA. …
0
votes
2 answers

Efficient way to read a small file from a very large Zip file in Java

I was wondering if there is any efficient way to read a small file from a very large zip. I am not interested in any other file in the zip except a small file called inventory.xml. To be exact, the zip file resides in artifactory. So I don't want to…
0
votes
0 answers

How to read multiple-encoded zip file

In my java web application when I upload a Zip file (thread dump), I get inputstream in servlet. I use the Zip4j library to unzip the file and then write it into a file. This zip file has multi encoded content (UTF-8, windows-1252, ISO-8859-1,…
Mahesh
  • 103
  • 1
  • 10
0
votes
1 answer

How to correctly close nested ZipInputStreams?

I am reading a nested zip file (a zip file containing multiple other zip files) in memory with the following code try (ZipInputStream zis = new ZipInputStream(inputStream)) { ZipEntry zipEntry; while ((zipEntry = zis.getNextEntry()) != null)…
flauschtrud
  • 690
  • 7
  • 23