5

I have created the Zip file using ZipOutputStream. The zip file is created sucessfully and able to open using WinRar and Winzip file. And the files are showing inside the Zip File.

But same file, I am unable to open in Windows 7 default Zip Extractor. While trying to extract using Windows 7 default extractor, there is no files inside the Zip File. But actually there are multiple files available inside the Zip File.

Please help on this... Thx..

Anujith
  • 9,370
  • 6
  • 33
  • 48
  • 1
    Do you have any file names in the zip file with non-ASCII characters? Encoding of file names in ZIP files is [a tricky area](http://ant.apache.org/manual/Tasks/zip.html#encoding) and there's no single approach that will work everywhere. – Ian Roberts Feb 15 '13 at 11:12
  • Yes... I am trying to create the Zip file for 10 Pdfs and 5 JPG in java. – user2075087 Feb 15 '13 at 11:28
  • I mean the names of the files, not their contents - a binary file named `august.pdf` is OK, one named `août.pdf` may be problematic. – Ian Roberts Feb 15 '13 at 11:31
  • The long and sad story of unicode support in compressed folders http://blogs.msdn.com/b/michkap/archive/2012/01/04/10252916.aspx – Sheng Jiang 蒋晟 Feb 15 '13 at 21:53
  • https://stackoverflow.com/questions/60745803/cannot-open-generated-zip-file This link helped me fix my issue. – Divije Narasimhachar Nov 04 '20 at 09:40

3 Answers3

2

My relative path was /somefolder/somefile.txt when removing the first "/" everything started working perfectly. (using the following path instead: "somefolder/somefile.txt").

benchuk
  • 669
  • 7
  • 13
0

Try this, it worked for me

File zipedFile = new File(OUTPUT_ZIP_FILE);
 zipedFile.setWritable(true);
MathieuF
  • 3,130
  • 5
  • 31
  • 34
Sedhu
  • 723
  • 1
  • 11
  • 36
0

Try:

outPutStream.putNextEntry(new ZipEntry(file.getName()));
webDeveloper
  • 1,284
  • 3
  • 16
  • 31