aspose file tools*
The moose likes I/O and Streams and the fly likes Problem with Unzipping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Problem with Unzipping " Watch "Problem with Unzipping " New topic
Author

Problem with Unzipping

Sanny kumar
Ranch Hand

Joined: May 18, 2005
Posts: 53
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

Joined: Jul 08, 2003
Posts: 24166
    
  30

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.


[Jess in Action][AskingGoodQuestions]
Sanny kumar
Ranch Hand

Joined: May 18, 2005
Posts: 53
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

Joined: Jul 08, 2003
Posts: 24166
    
  30

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.)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with Unzipping
 
Similar Threads
problem in attached file .
Problme with unzipping
Problem in unzipping a folder using java.util.zip API
unzip problem, I give up now
Problem unzipping with ZipInputStream, containing filename with Swedish characters