Skip to content

Instantly share code, notes, and snippets.

@itog
Created December 28, 2009 15:51
Show Gist options
  • Save itog/264740 to your computer and use it in GitHub Desktop.
Save itog/264740 to your computer and use it in GitHub Desktop.
public void extractZipFiles(String dest, String zipName) {
try {
AssetManager assetManager = context.getAssets();
InputStream inputStream = assetManager.open(zipName, AssetManager.ACCESS_STREAMING);
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
ZipEntry zipEntry = zipInputStream.getNextEntry();
while (zipEntry != null) {
String entryName = zipEntry.getName();
int n;
FileOutputStream fileOutputStream;
fileOutputStream = new FileOutputStream(dest + "/" + entryName);
byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
while ((n = zipInputStream.read(buf, 0, DEFAULT_BUFFER_SIZE)) > -1) {
fileOutputStream.write(buf, 0, n);
}
fileOutputStream.close();
zipInputStream.closeEntry();
zipEntry = zipInputStream.getNextEntry();
}
zipInputStream.close();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment