Created
December 28, 2009 15:51
-
-
Save itog/264740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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