Results 1 to 5 of 5
  1. #1
    aloula is offline Member
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    Question dealing with (zip) files

    hi guys..

    is there any - well documented - library that supports dealing with encrypted compressed files (zip, rar, 7z, ..etc)



    any help would be appreciated

    thanks in advance :)
    Last edited by aloula; 10-03-2009 at 10:43 AM.

  2. #2
    Dieter's Avatar
    Dieter is offline Member
    Join Date
    Sep 2009
    Posts
    91
    Rep Power
    0

    Default

    Check API.

    if you asking how to create a zip and read a zip, then i got a code example for you.

    Making a zipped file..

    Java Code:
    package ZipWars;
    
    import java.io.*;
    import java.util.zip.*;
    
    public class Zipping {
    	public static void main(String[] args) throws IOException{
    		
    		ZipOutputStream out = new ZipOutputStream(new 
    		BufferedOutputStream(new FileOutputStream("c:\\CrapMap\\ZipWarsFirstExample.zip")));
    		byte[] data = new byte[10000];     
    		
    	try{
    		BufferedInputStream in = new BufferedInputStream
    						(new FileInputStream("c:\\CrapMap\\KlantenBestand.txt.txt"));
    		
    		out.putNextEntry(new ZipEntry("c:\\CrapMap\\KlantenBestand.txt.txt"));
    		int count;
    	 	while((count = in.read(data,0,10000)) != -1){
           		
    		out.write(data, 0, count);
    		}
    	 	in.close();
    	        out.flush();
    	        out.close();
    		System.out.println("Your file is zipped");
    		
    	}catch(Exception e){
     		e.printStackTrace();
    	 }
    	}
      }
    Reading from the zipped file...

    Java Code:
    package ZipWars;
    
    import java.io.*;
    import java.util.zip.*;
    
    
    
    public class ReadIt {
    	public static void main(String[] args) throws IOException{
    	 	ZipInputStream zis = null;
    
    	    FileInputStream fis = new FileInputStream("c:\\CrapMap\\ZipWarsFirstExample.zip");
    	    zis = new ZipInputStream(fis);
    
    	    ZipEntry ze;
    
    	    while ((ze = zis.getNextEntry()) != null)
    	      System.out.println(ze.getName());
    
    	}
    }
    Also you can do this all with the DeflaterOutputStream.

    All the best,

    Dieter
    Programming today is a race between software engineers striving to build bigger and better idiot proof programs,and the Universe trying to produce bigger and better idiots...

  3. #3
    Dieter's Avatar
    Dieter is offline Member
    Join Date
    Sep 2009
    Posts
    91
    Rep Power
    0

    Default

    Note that i made a mistake with the FilePath. So you need to change that.
    Programming today is a race between software engineers striving to build bigger and better idiot proof programs,and the Universe trying to produce bigger and better idiots...

  4. #4
    aloula is offline Member
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    Default

    Dear Dieter ..

    thanks for your assistance, but what I want exactly is the way of unzipping ((encrypted)) files..

    is there a library supporting encrypted (zip, rar, ...etc) files?

    if there is, I'll appreciate a sample code :)

    thanks a lot..

  5. #5
    Dieter's Avatar
    Dieter is offline Member
    Join Date
    Sep 2009
    Posts
    91
    Rep Power
    0

    Default

    try API, i'm sure u will find your way in there.
    Programming today is a race between software engineers striving to build bigger and better idiot proof programs,and the Universe trying to produce bigger and better idiots...

Similar Threads

  1. Replies: 2
    Last Post: 09-23-2009, 07:46 PM
  2. Dealing with iReport 3.0.0
    By HotEvilGirl in forum New To Java
    Replies: 6
    Last Post: 09-11-2009, 12:32 PM
  3. Inconsistencies dealing with null
    By xcallmejudasx in forum New To Java
    Replies: 3
    Last Post: 05-11-2009, 09:58 PM
  4. working with files (text files)
    By itaipee in forum New To Java
    Replies: 1
    Last Post: 02-24-2009, 12:38 PM
  5. Behaving text files like binary files
    By Farzaneh in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 04:20 PM

Posting Permissions

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