I wrote some code using ZipInputStream but there is something wrong with it.
ZipInputStream zin=null;
zin=new ZipInputStream(new BufferedInputStream(
new FileInputStream("e:/testzip.zip")));
ZipEntry ze;
while((ze=zin.getNextEntry())!=null) {
System.out.println("readfile"+ze.getName());
int c=0;
while((c=zin.read())>0) {
System.out.write(c);
}
}
zin.close();
There are 3 text files in the testzip.zip. That is, the right output should be the three file names and their contents. However, my output are 3 file names and 2 of their contents. Why only 2 contents, rather than 3?
I made a zip with 3 textfiles in; the fact that they are textfiles is important for the following code to work. I read all entries and write out it’s names and contents: