Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Unzipping

 
Sanny kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic