• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Problem with Unzipping

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
i have a directory.in tht directory there are many ZIP files.i want to extract all the files frm tht zip file.

my main aim is to extract all the files if a directory name is given..

i m getting exception like this:
java.util.zip.ZipException: The system cannot find the file specified

the code is all follows:



JE: added code tags to preserve formatting
[ December 13, 2005: Message edited by: Joe Ess ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That error you give is the first line of the stack trace that gets printed. One of the next few lines will show you the exact line number where the error occurs in your program. If that's not a help to you, it would certainly be to us -- so please let us know exactly which line in your program is causing this error.
 
Sanny kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

after the filename is passed to the static method.
i m getting the file name when i do System.out.println(fname);

after the next line i m getting error


Thanks in advance
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That file.list() call is going to return the names of the files in that directory, but unless that directory is the current directory, the ZipFile constructor won't be able to find them. Instead of using list() use listFiles(), which returns File object instead of Strings, and pass aFile.getAbsolutePath() to Unzipme() (or change Unzipme() to take a File argument, and just pass the File.)
 
reply
    Bookmark Topic Watch Topic
  • New Topic