Results 1 to 3 of 3
  1. #1
    profman is offline Member
    Join Date
    Sep 2012
    Rep Power

    Exclamation Password protected zip files and Java

    Hi all. Sorry if this is in wrong section. Please move to relevant section and I will make a note in future :)

    So i am quite new to java and have been thrown in the deep end. I have a requirement:-

    I need to write a method to check whether

    A: A zip file is password protected AND
    B: The password is "password".

    I am using zip4j library.

    The code I have so far is below but I am sure it is wrong. Can someone please help me? I would be very grateful...

    import net.lingala.zip4j.core.ZipFile;
    import net.lingala.zip4j.exception.ZipException;

    public class Main {
    public boolean isZipProtected(InputStream zipFile);
    public static void main(String[] args) throws IOException {
    ZipFile zipFile = new ZipFile("c:\\zip\\");

    // Check to see if the zip file is password protected
    if (zipFile.isEncrypted()) {
    // if yes, then set the password for the zip file

    zipFile.extractFile("*", "c:\\zip\\TEMPLOCATION\\");
    InputStream input = new FileInputStream(zipFile);
    return true;
    }catch(ZipException ex){
    System.out.println("error "+ ex );


  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Password protected zip files and Java

    BB Code List - Java Programming Forum

    Edit your post and add the tags.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Password protected zip files and Java

    Does the above code work?
    If not then what errors/exceptions are you getting, complete with any stack trace and highlighting the line causing the problem.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 17
    Last Post: 05-22-2012, 01:19 PM
  2. Replies: 0
    Last Post: 09-14-2011, 09:44 AM
  3. Indexing Password-protected word files?
    By pleonastic in forum Lucene
    Replies: 0
    Last Post: 02-17-2011, 04:43 PM
  4. Replies: 2
    Last Post: 03-23-2010, 04:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts