I have 2 file in a zip file I use:
while( (entry = zis.getNextEntry()) != null){
if(entry.getName() == null ? gomrokcode != null : !entry.getName().equals(gomrokcode))
maxversion=0;
Scanner scanner = new Scanner(zis);
while(scanner.hasNextLine()){
line = scanner.nextLine();
}
scanner.close();
}
zis.close();
for accessing the files i get first file , and then when I return to the start of loop for second file I get this exception
SEVERE: null
java.io.IOException: Stream closed
at java.util.zip.ZipInputStream.ensureOpen(ZipInputStream.java:66)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:115)
what is the reason?
You wrap your zis stream with a Scanner, and when you close the Scanner it will close the zis stream. Hence the execption.
If you remove the scanner.close() call, I guess the iteration will proceed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With