Results 1 to 1 of 1
Thread: Creating a zipped file
- 09-30-2009, 08:29 PM #1
Creating a zipped file
hey hey,
yes i know, "him again" :p
well i got the following question.
i want to create a zipped file but when i create it and i go into the zipped file and want to read the files in it it gave me an error files not found.
i don't know what i'm doing wrong or what i'm missing but u tried different things but ended up with more errors.
this is the code i have so far...
i hope you will help me solve this problem.Java Code:package ZipTheFiles; import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import java.util.*; public class TheReturnOfTheZip { public static void main(String[] args){ String[] filenames = new String[]{"c:\\CrapMap\\KlantenBestand.txt.txt", "c:\\CrapMap\\KlantenBestand2.txt.txt"}; byte[] buf = new byte[1024]; BufferedInputStream bif; try { String outFilename = "c:\\CrapMap\\ZipIsHip.zip"; ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outFilename))); FileInputStream in; for (int i=0; i<filenames.length; i++) { in = new FileInputStream(filenames[i]); bif = new BufferedInputStream(in); ZipEntry zipEntry = new ZipEntry(filenames[i]); out.putNextEntry(zipEntry); int len,pos=0; while ((len = bif.read(buf,0,1024)) != -1) { out.write(buf, 0, len); pos+=len; } out.closeEntry(); bif.close(); System.out.println("succes"); } out.finish(); out.close(); } catch (IOException e) { } } }
ps: this is someting i dont get at school, i figured this out by myself.
at school we need to use the DeflaterOutputStream, but i wanted to try this since this looks better then the DeflaterOutputStream.
thx in advance,
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...
Similar Threads
-
Importing a zipped package to Eclipse
By Abder-Rahman in forum EclipseReplies: 10Last Post: 02-24-2010, 05:26 PM -
Creating a .jar file
By Wataru in forum New To JavaReplies: 3Last Post: 07-22-2009, 06:02 AM -
Creating jar file
By Heather in forum Advanced JavaReplies: 4Last Post: 02-11-2009, 09:58 AM -
creating jar file
By po0oker in forum Advanced JavaReplies: 3Last Post: 04-04-2008, 07:49 PM -
creating .ear file
By psn in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 01-06-2008, 05:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks