Results 1 to 5 of 5
Thread: dealing with (zip) files
- 10-03-2009, 09:37 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 2
- Rep Power
- 0
- 10-05-2009, 10:37 AM #2
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..
Reading from the 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(); } } }
Also you can do this all with the DeflaterOutputStream.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()); } }
All the best,
DieterProgramming 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...
- 10-05-2009, 10:40 AM #3
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...
- 10-06-2009, 11:42 AM #4
Member
- Join Date
- Oct 2009
- Posts
- 2
- Rep Power
- 0
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..
- 10-06-2009, 07:32 PM #5
Similar Threads
-
dealing with database in wireless mobile midlet problem!
By coldvoice05 in forum JDBCReplies: 2Last Post: 09-23-2009, 06:46 PM -
Dealing with iReport 3.0.0
By HotEvilGirl in forum New To JavaReplies: 6Last Post: 09-11-2009, 11:32 AM -
Inconsistencies dealing with null
By xcallmejudasx in forum New To JavaReplies: 3Last Post: 05-11-2009, 08:58 PM -
working with files (text files)
By itaipee in forum New To JavaReplies: 1Last Post: 02-24-2009, 11:38 AM -
Behaving text files like binary files
By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks