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
1
vote
1 answer

Zipped file isn't unarchiving

The following code downloads a zip file. Am I doing something wrong here? The zip file downloads but can't unarchive. ByteArrayOutputStream baos = getByteArrOutputStream(); ZipOutputStream zos = new ZipOutputStream(baos); …
h-rai
  • 3,636
  • 6
  • 52
  • 76
1
vote
4 answers

When using ZipOutputStream to create an ODT file in java fails to open in OpenOffice

I have the following method to add zip entries to a ZipOutputStream: private void addFile(String filename, byte[] bytes, ZipOutputStream zos, boolean encrypt) throws IOException { ZipEntry entry = new ZipEntry(filename); if…
1
vote
5 answers

how to check if a ZIP file is empty in Java?

I have the following piece of code - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(outputStream); for (int i = 0; i < params.getGrades().size(); i++) { generateReport(param1, param2,…
Raaz
  • 125
  • 1
  • 5
  • 16
1
vote
1 answer

Need a way to instantiate ZipOutputStream object in the service layer

I have the following block of code in my bean class - HttpServletResponse response = (HttpServletResponse) getFacesContext().getExternalContext().getResponse(); ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); From my bean I…
Raaz
  • 125
  • 1
  • 5
  • 16
0
votes
1 answer

Error Creating zip file In Memory using Java

Here is the code that I'm using to create a zip file: ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream out = new ZipOutputStream(baos); try { for(int i=0; i
keith h
  • 83
  • 3
  • 10
0
votes
1 answer

Generated zip file is always corrupted after download on Mac

Lets say that I have a collection of objects which I would like to wrap with zip. My zip conversion class looks like: public class ZipFile { public byte[] createZipByteArray(String fileName, byte[] content) throws IOException { …
Martin
  • 1,139
  • 4
  • 23
  • 49
0
votes
0 answers

PrintStream to ZipOutputStream properly close

To produce two diferent files to a ZipStream I am using two methods receiving an outputStream something like this: private void produceFileA (OutputStream stream){ final PrintStream printer = new PrintStream (stream); ...... } private void…
rdim66
  • 1
  • 1
0
votes
1 answer

How to create a zip file from binary data without knowing contents of zip file in java?

I am listening to binary data from queues which is actually a zip file data. I want to reconstruct the zip file using java code but I do not have any information about contents of zip file such as no of files, names of files and size of each file in…
0
votes
1 answer

write large HSSFWorkbook into OutputStream with ZipOutputStream

Really appreciate the assistance since I am stuck here I am Trying to download .xls file/files in zip format Works fine when there are small amount of data like 150 records in xls file But once the data is huge it fails to download. it redirects to…
0
votes
0 answers

what are special characters not allowed to set in net.lingala.zip4j.model.ZipParameters.setFileNameInZip?

I am creating encrypted zip using zip4j_1.3.2.jar. below is my rough code. zipParameters.setFileNameInZip(fileName); in this line if fileName is containing slash special character or filename equals to "/" after downloading zip file, file size is 0…
0
votes
1 answer

The archive is corrupt / warning 'headers error' ... but everything works? (zip64)

I am zipping (using zip64) a number of files and then returning it in a response to the user. response.setContentType("application/zip"); // Doesn't seem like this makes any difference? response.setHeader("Content-Disposition",…
Sebastian Nielsen
  • 3,835
  • 5
  • 27
  • 43
0
votes
0 answers

Make zip from directory and download it In Spring without creating new files or directories

I have a sample directory called 'sample-directory'(in resources) with files and directories in it. this is my endpoint: public void downloadZipFile(@RequestBody final Parameters parameter, final HttpServletResponse response) throws…
0
votes
1 answer

ZipOutputStream does not create new entries for Directories

I am trying to create directories in a .zip file but only one directory is being created in the .zip. I'm not sure why only the first directory gets created. zip() method gets called everytime theres a directory. Method to list files: private…
kpwn Apps
  • 115
  • 1
  • 8
0
votes
1 answer

Memory allocation error when trying to create a large zip file in memory

The memory allocation error specifically seems to occur once it hits the for loop and only for very large storesLists. I only able to hit the memory allocation error if storesList.size() is about 2 million. I've pasted a snipped of the for loop…
Brandon Hu
  • 93
  • 6
0
votes
1 answer

ZipFile : Wrong values when reading

I am creating a zip file with one directory and an single compressed text file inside of it. Code to create the zip file try(ZipOutputStream zos=new ZipOutputStream(new FileOutputStream("E:/TestFile.zip"))) { //comment,level,method for…
Sync it
  • 1,180
  • 2
  • 11
  • 29