-
Extract Zip archive with password
I searched alot but couldn't find something useful regarding this subject.
Can anyone help me with this. What type of stream can send password...
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.zip.*;
public class Ziptest
{
public static final void copyInputStream(InputStream in, OutputStream out) throws IOException
{
byte[] buffer = new byte[1024];
int len;
while((len = in.read(buffer)) >= 0)
out.write(buffer, 0, len);
in.close();
out.close();
}
public static final void main(String[] args) {
Enumeration entries;
ZipFile zipFile;
if(args.length != 1) {
System.err.println("Usage: Unzip zipfile");
return;
}
try {
zipFile = new ZipFile(args[0]);
entries = zipFile.entries();
while(entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
if(entry.isDirectory()) {
// Assume directories are stored parents first then children.
System.err.println("Extracting directory: " + entry.getName());
// This is not robust, just for demonstration purposes.
(new File(entry.getName())).mkdir();
continue;
}
System.err.println("Extracting file: " + entry.getName());
copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(entry.getName())));
}
zipFile.close();
}
catch (IOException ioe)
{
System.err.println("Unhandled exception:");
ioe.printStackTrace();
return;
}
}
}
Any suggestions ????
Any help would ve very appreciated.
Similar Threads
-
Replies: 3
Last Post: 05-22-2005, 02:28 PM
-
By Tricia in forum VB Classic
Replies: 6
Last Post: 03-30-2002, 01:23 PM
-
By Jeffrey Nuestro in forum Database
Replies: 4
Last Post: 01-30-2002, 10:08 PM
-
Replies: 0
Last Post: 08-06-2001, 06:54 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks