problem with zipinputstream class


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: problem with zipinputstream class

  1. #1
    dinesh Guest

    problem with zipinputstream class


    os:windows95
    application:jdk1.3

    hi everybody:
    here is a code written to connect to a password protected url and
    also to see the contents of that site.
    the url listed in the code contains a zip file(content type application/x-gzip)
    i have connected to that site through URLConnection class and created a
    ZipInputStream to print name of each zipEntry in that file but the program
    only
    prints the content type and content length and comes out it doesnt print
    the list of files in that zip archive.
    please any body help me
    (if u want to connect to that site
    for verification please type this url in the address bar of u r browser
    http://fdg852dp:wxx853dq@link.spring...16-tocs.tar.gz)
    thanks in advance
    dinesh


    import java.io.*;
    import java.net.*;
    import java.util.zip.ZipInputStream;
    import java.util.zip.ZipEntry;
    class zipfoldt
    {

    public zipfoldt()
    {}
    public static void main(String args[])
    {

    String url="http://link.springer.de/customer/service/mirr/tocs/2000-10-16-tocs.tar.gz";
    String userid="fdg852dp";
    String passwd="wxx853dq";


    try
    {
    /* BufferedReader bo=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("entet the url");
    url=bo.readLine(); */
    URL u=new URL(url);
    String compress= userid+":"+passwd;
    String encoding=new sun.misc.BASE64Encoder().encode(compress.getBytes());
    URLConnection uc= u.openConnection();
    uc.setRequestProperty("Authorization","Basic "+encoding);
    uc.connect();
    InputStream in1= (InputStream)uc.getInputStream();
    System.out.println(uc.getContentType());
    int length=uc.getContentLength();
    System.out.println(length);
    ZipInputStream in=new ZipInputStream(in1);
    ZipEntry zip;

    /* getNextEntry() method reads the next ZIP file entry and
    positions stream at the beginning of the entry data and returns
    zipEntry */

    while((zip=in.getNextEntry())!=null)
    {
    System.out.println(zip.getName());
    System.out.println(zip.getSize());
    in.closeEntry();
    }
    }catch(Exception e){System.out.println(e);}
    }
    }


  2. #2
    Paul Clapham Guest

    Re: problem with zipinputstream class

    Fortunately the URL is not actually password-protected, so I could download
    the file. It isn't exactly a zip file; I tried to open it with WinZip and
    it said "Archive contains one file: 2000-10-16-tocs.tar Should WinZip
    decompress it to a temporary folder and open it?". So it only contains one
    file, and that's a Unix tar-format archive file that contains many files.

    Why don't you download the file and see if you can get the ZipInputStream to
    work from your local hard drive? Right now you are testing URLConnection
    and ZipInputStream at the same time, and it's always better to test only one
    thing at a time.

    PC2

    dinesh <dineshjayaraj@yahoo.com> wrote in message
    news:3a24fe60$1@news.devx.com...
    >
    > os:windows95
    > application:jdk1.3
    >
    > hi everybody:
    > here is a code written to connect to a password protected url and
    > also to see the contents of that site.
    > the url listed in the code contains a zip file(content type

    application/x-gzip)
    > i have connected to that site through URLConnection class and created a
    > ZipInputStream to print name of each zipEntry in that file but the program
    > only
    > prints the content type and content length and comes out it doesnt print
    > the list of files in that zip archive.
    > please any body help me
    > (if u want to connect to that site
    > for verification please type this url in the address bar of u r browser
    >

    http://fdg852dp:wxx853dq@link.spring...r/tocs/2000-10
    -16-tocs.tar.gz)
    > thanks in advance
    > dinesh
    >





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center