Questions tagged [zipoutputstream]

ZipOutputStream is used to write ZipEntrys to the underlying stream. Output from ZipOutputStream can be read using ZipFile or ZipInputStream.

A ZipOutputStream is a mechanism for writing data to a stream in a zip-compressed format. A stream is usually comprised of data to write to a local file, or data being transmitted to a remote server over a network protocol such as HTTP or FTP. As the data is given to the ZipOutputStream, it is compressed, and then transmitted to the stream.

170 questions
54
votes
5 answers

Spring REST - create ZIP file and send it to the client

I want to create a ZIP file that contains my archived files that I received from the backend, and then send this file to a user. For 2 days I have been looking for the answer and can't find proper solution, maybe you can help me :) For now, the code…
azalut
  • 4,094
  • 7
  • 33
  • 46
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
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
15
votes
2 answers

How to create a multipart zip file and read it back?

How would I properly zip bytes to a ByteArrayOutputStream and then read that using a ByteArrayInputStream? I have the following method: private byte[] getZippedBytes(final String fileName, final byte[] input) throws Exception { …
Benny
  • 1,508
  • 3
  • 18
  • 34
15
votes
3 answers

write a XSSFWorkbook to a zip file

I now have this problem. I want to write a excel file hold in this XSSFWorkbook (workbook) obj into a zip file eg(example.zip while contain this example.xlsx file) to a remote server. I have tried following but not working, it created a folder…
user1721910
  • 161
  • 1
  • 1
  • 4
14
votes
4 answers

Upload ZipOutputStream to S3 without saving zip file (large) temporary to disk using AWS S3 Java

I have a requirement to download photos (not in same directory) from S3, ZIP them and again upload to S3 using AWS S3 Java SDK. This zip file size can go in GBs. Currently I am using AWS Lambda which has a limitation of temporary storage up to 500…
pankaj
  • 1,643
  • 4
  • 22
  • 35
14
votes
2 answers

How to create a zip file of multiple image files

I am trying to create a zip file of multiple image files. I have succeeded in creating the zip file of all the images but somehow all the images have been hanged to 950 bytes. I don't know whats going wrong here and now I can't open the images were…
Vighanesh Gursale
  • 921
  • 5
  • 15
  • 31
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
3 answers

"IllegalArgumentException: UNMAPPABLE[1]" while zipping a file with Greek characters

I want to zip a file on Windows (7) with ZipOutputStream. The Problem is that the file name (and file file Content too) contains also Greek characters ("ГП0000660040140521_a.txt", Gamma and Pi). The code to zip the file I use: ZipOutputStream zipOs…
Steffen
  • 2,500
  • 4
  • 31
  • 47
8
votes
1 answer

Convert ZipOutputStream to ByteArrayInputStream

I want to compress an InputStream using ZipOutputStream and then get the InputStream from compressed ZipOutputStream without saving file on disc. Is that possible?
yasser
  • 401
  • 1
  • 4
  • 10
8
votes
3 answers

How do you add a folder to a zip archive with ICSharpCode.SharpZipLib

I have to create two folders inside of a zip file that I create programmatically using ICSharpCode.SharZipLib.Zip. I want to: private void AddToZipStream(byte[] inputStream, ZipOutputStream zipStream, string fileName, string fileExtension) …
Saturn K
  • 2,705
  • 4
  • 26
  • 38
7
votes
2 answers

create and download the Zip file java

In my application there are no of documents(pdf) for a particular tender. I need to create a zip file from those pdf files and allow user to download it. Application is done in JavaEE with struts and mysql. when user clicks the download button this…
Bhugy
  • 711
  • 2
  • 8
  • 23
7
votes
1 answer

Java.util.zip replace a single zip file

Problem I have an existing zipfile "main.zip". I want to replace a single file in it, "say main.zip/foo." I am aware of: http://docs.oracle.com/javase/7/docs/api/java/util/zip/ZipOutputStream.html However, this does not do what I want, as it creates…
user1647794
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
2 answers

ZipEntry.STORED for files that are already compressed?

I am using a ZipOutputStream to zip up a bunch of files that are a mix of already zipped formats as well as lots of large highly compressible formats like plain text. Most of the already zipped formats are large files and it makes no sense to spend…
user177800
1
2 3
11 12