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
2 answers

Java.util.zip.ZipException: invalid entry size (expected 18401 but got 0 bytes) when using putNextEntry() in ZipOutputStream?

I converted a zip file of 5 files into a byte array. I want to output a zip file on my disk from that bytearray. My process was first reading the byte[] into a ByteArrayInputStream then into a ZipInputStream. InputStream plainTextStream = new…
1
vote
1 answer

Prevent removing duplicates from ZipOutPutStream

I am using this functionalities to zip bunch of files, but the problem is if the there are two file names with different content but with the same original name, then only one file is been zipped, how can i prevent this by adding a number to file…
Catalina
  • 663
  • 5
  • 20
1
vote
3 answers

How to extract zip archive with subdirectories using SAF / DocumentFile?

I'm struggling with extracting a zip file contents using the evil Storage Access Framework, as you may know; I can't use any File objects so I have to use ZipInputStream, ZipOutputStream and DocumentFile, Here's the zip file structure: Folder 1/ABC…
Al_HK
  • 65
  • 1
  • 9
1
vote
1 answer

Is it possible to exclude files and/or directories when using GZIPOutputStream or ZIPOutputStream in java?

I am trying to archive all the files in the root directory of the folder but have the backups as one of the folders in the root directory so I wanted to exclude it so each backup after the first one isn't backing up the backups folder (aka…
JordanPlayz158
  • 81
  • 1
  • 11
1
vote
1 answer

Add JarOutputStream to ZipOutputStream

currently I have generated a JarOutputStream and a Directory filled with *.java files. I want to add the final JarOutputStream to a ZipOutputStream to return a final *.zip file with the directory and the *.jar file. Now I wanted to know, how and if…
tud_mb
  • 65
  • 6
1
vote
1 answer

Is the compression happening after the encryption?

While reviewing an encryption scheme, I came accross the following code: @Override public OutputStream encrypt(OutputStream outputStream) throws Exception { // generate the IV for encryption final byte[] encryptionIV =…
phil
  • 313
  • 1
  • 4
  • 13
1
vote
1 answer

Fortify Privacy Violation in ZipOutputStream.write() method

In Fortify code scan, we have a privacy violation in below Java code, which converts a byte[] to ZipOutputStream, which is later converted to another byte[]. The exact sink line is zos.write(arr); private byte[] zipFile(String filename, byte[] arr)…
User_1940878
  • 321
  • 1
  • 6
  • 25
1
vote
1 answer

Download Zip file from azure Storage c#

I am looping through the file names from my database and the same file i have in azure storage. I am zipping those n number of files and download from azure storage. I saves the zipped file to my local storage. When i extract and want to see a file,…
bbajwa9366
  • 21
  • 1
  • 6
1
vote
2 answers

Invalid zip while compressing with ZipOutputStream

I get invalid zip, when writting to file the following code: public static byte[] zip(final Map mapReports) { try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(baos)) { …
Gilo
  • 640
  • 3
  • 23
1
vote
0 answers

zip file corrupted or has NUL bytes at the beginning correct it and re create the zip in Java

we are receiving a zip file through http post url,some times this zip file is corrupted or while zipping from source contains NUL bytes while it is adding the files to the zip when ever it takes more time to create the files to zip. Now we have…
1
vote
2 answers

How do I write chinese charactes in ZipEntry?

I want to export a string(chinese text) to CSV file inside a zip file. Where do I need to set the encoding to UTF-8? Or what approach should I take (based on the code below) to display chinese characters in the exported CSV file? This is the code I…
1
vote
0 answers

Java: ZipOutputStream to compress chunks of data to single zip file

Follow up of Question: Java: how to compress a byte[] using ZipOutputStream without intermediate file I can zip data without an intermediate file (or memory file). I now need to zip chunks of data and add them to a single zip file. I am using a…
1
vote
1 answer

When i close the zipoutputstream does the writer objects associated with it will also be closed and cleaned by GC

Trying to create a ZIP file having 3 files inside it. I am using ZipOutputStream for creating ZIP file and Printwriter to create and write files into Zip. When i close printwriter object after writing a file closes the stream as well, which i know.…
1
vote
3 answers

Put Inputstream containing multiple files into one ZipEntry

I want to zip an array of File to a zipfile and send it to the browser. The Inputstream of each File is a shapefile, and actually consists of multiple files (.shp, .dbf, .shx, ...). When I send only one File with the following code, it works…
Toik95
  • 157
  • 1
  • 2
  • 13
1
vote
2 answers

UTF-8 is not working for Java zipOutputStream

I am generating a zip file containing csv using ZipOutputStream. I have passed the encoding UTF-8 but the problem is that German umlauts are not compressed properly. When uncompressed, they do not appear properly in the file. I am not sure if the…
nullvoid
  • 45
  • 1
  • 1
  • 11