Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can't properly unzip archive when use ZipInputStream

817788Sep 4 2011 — edited Sep 6 2011
Hello.
Have some problem with ZipInputStream.
I have two simple tasks:
1. Download zip file from web.
2. Unzip file.
Zipped archive contains four text files.
So, all of the above is simply resolved with a help of ZipFile class, but when i use ZipInputStream, i got only one of four files unzipped in output, where i am did a mistake?

Here is the code:
URL url01=new URL(....);
ZipInputStream zis01=new ZipInputStream(url01.openStream());
            ZipEntry zipEntry;
          while((zipEntry=zis01.getNextEntry())!=null){
                if(!zipEntry.isDirectory()){
                    PrintStream ps01=new PrintStream(new FileOutputStream(zipEntry.getName()),true);
                    BufferedReader bffr01=new BufferedReader(new InputStreamReader(zis01));
                   String line;
                    while((line=bffr01.readLine())!=null){
                        ps01.println(line);
                    }
                    ps01.close();
                }
                zis01.closeEntry();
            }
            zis01.close();
Edited by: 814785 on Sep 4, 2011 6:03 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2011
Added on Sep 4 2011
15 comments
1,776 views