Zip Reader : Zip « Development « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » Development » Zip 
Zip Reader
 

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

class ZipReader {
  private static final File file = new File("/sdcard/a.zip");
  
  public static Bitmap getBitmap(String namethrows IOException {
    Bitmap result = null;
    ZipFile zip = null;
    try {
      zip = new ZipFile(file, ZipFile.OPEN_READ);
    
      ZipEntry entry = zip.getEntry(name);
      if (entry != null && !entry.isDirectory()) {
        InputStream is = null;
        try {
          is = zip.getInputStream(entry);
          result = BitmapFactory.decodeStream(is);
        finally {
          if (is != null) {
            is.close();
          }
        }
        
      }
    finally {
      if (zip != null) {
        zip.close();
      }
    }
    return result;
  }

}

   
  
Related examples in the same category
1.Zip Util
2.unzip
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.