1

I want to extract only image files inside a zip file. Any examples about this? How do I do this?

Solved this problem already.

Added a missing statement getInputStream()

Lawrence Gimenez
  • 2,662
  • 4
  • 34
  • 52

1 Answers1

1

Take a look at this answer for how to unzip a file. You could alter it by adding a filter on the ze.getName() to filter using a list of image extensions you are looking for.

Community
  • 1
  • 1
brianestey
  • 8,202
  • 5
  • 33
  • 48
  • I'm unzipping it using only the emulator, after unzipping, the file sizes are all 0 bytes. What happened? – Lawrence Gimenez Jan 17 '12 at 04:10
  • Where are you unzipping to? Was there any kind of exception? – brianestey Jan 17 '12 at 05:01
  • Unzipped it to folder I created, there's no exception. The files are all 0 bytes, is this because I run it in emulator? – Lawrence Gimenez Jan 17 '12 at 05:16
  • I've never used the emulator. I guess it's possible, but I find it highly unlikely. You could add logging to the function to ensure that each file is being found, check the filesize of the file `ze.getSize()` to ensure it's not zero and make sure that the part that's reading the zip file actually reads some data. – brianestey Jan 17 '12 at 05:43