File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes java.util.zip and a password-protected zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "java.util.zip and a password-protected zip file" Watch "java.util.zip and a password-protected zip file" New topic
Author

java.util.zip and a password-protected zip file

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
I'm trying to unzip files from within my Java program. Before I would try to just exec a process that would run pkunzip on my files, but I've been trying that on a Win2003 machine and would always get a strange error from Windows saying something about the environment not being set up (and yes, I was hardcoding the path to pkunzip). Anyway, for some strange reason I don't get that error anymore (and I didn't change anything on the server myself), but I had already started working on trying to use the java.util.zip package's classes to do this from pure Java code, so I'm now wondering if there's any way from within this Java package to unzip an encrypted (password-protected) zip file. Here's what I have so far:



[ August 24, 2004: Message edited by: Stephen Huey ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Reference Website
How do I unzip a file that is password-protected?

This will hekp you....


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
In the article provided by somkiat, it said that "The Java classes that read Zip files, e.g. ZipInputStream, do not support decrypting password-protected Zip files."

Your application must find a way to let the user specify the password to decrypt the zip file... You might need to find the documents or manuals that explain how to deal with encryption and decryption with a certain zip file...

Just my 2 cents..


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
It would be easy to obtain a password from the user, but in looking at the API, I'm not really sure how to use the password obtained. However, I'm guessing this means that all the bytes of the file need to be decrypted using that password string...


Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Moving to I/O and Streams since Zip operations are Input/Output and Stream operations.


GenRocket - Experts at Building Test Data
Martin Matula
Greenhorn

Joined: Oct 31, 2009
Posts: 1
I wrote a simple class that can deal with a certain type of password-protected ZIPs in Java - here is more info: http://blog.alutam.com/2009/10/31/reading-password-protected-zip-files-in-java/
Martin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.util.zip and a password-protected zip file