• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with zip decompression

 
Moieen Khatri
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can someone please help with the below issue.

I cannot extract(unzip) the zip file content using the below code:



The above zipFileExtractor() method takes 3 paramters(source folder,destination folder,zip file name),I have placed the above zip file in the source folder.


The method which is called is given below:



When I run the main method I get null value in the below variable:


Can someone please help.

Thanks

 
Moieen Khatri
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just noticed that my code doesnt work for files with DURSME_1.xml.zip extension,however if the file has the extension DURSME_1.zip the code works fine.

Is there any workaround for this?I need the code to work for files with the extension .xml.gz,.xml.zip,.zip

Please can some help with this?


Many Thanks in advance!
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything in your code that would care about what extension your files have. The only way you could get null in zipFile is if there is an exception thrown. I suggest printing out a stack trace in your catch block. It's generally not a good idea to have empty catch blocks. Either handle the exception or log it in some way (or both).

Also, I suggest using "/" as the file separator. It works on every operating system I've tried (including Windows), and has the added advantage of not being so ugly. To be truly cross-platform, you really should query the system properties for the file separator, but in practice "/" always works anyway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic