Results 1 to 3 of 3
- 09-13-2012, 11:44 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 1
- Rep Power
- 0
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 java.io.IOException;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.io.Zip4jInputStream;
public class Main {
public boolean isZipProtected(InputStream zipFile);
public static void main(String[] args) throws IOException {
try{
ZipFile zipFile = new ZipFile("c:\\zip\\FILENAME.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.setPassword("password");
}
zipFile.extractFile("*", "c:\\zip\\TEMPLOCATION\\");
InputStream input = new FileInputStream(zipFile);
return true;
}catch(ZipException ex){
System.out.println("error "+ ex );
}
}
}
- 09-14-2012, 10:55 AM #2
Re: Password protected zip files and Java
BB Code List - Java Programming Forum
Edit your post and add the tags.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 09-14-2012, 12:28 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Similar Threads
-
Help needed in File download from password protected FTP server.
By Kuttappu in forum New To JavaReplies: 17Last Post: 05-22-2012, 01:19 PM -
connect to password protected access database
By Yama12 in forum JDBCReplies: 0Last Post: 09-14-2011, 09:44 AM -
Indexing Password-protected word files?
By pleonastic in forum LuceneReplies: 0Last Post: 02-17-2011, 04:43 PM -
Calling a .Net webservice(Password Protected) from java console application
By charan reddy in forum Advanced JavaReplies: 2Last Post: 03-23-2010, 04:46 AM
Bookmarks