Android 使用ZipFile类从多个文件的zip存档解压缩文件
我想使用Android 使用ZipFile类从多个文件的zip存档解压缩文件,android,unzip,zipfile,Android,Unzip,Zipfile,我想使用ZipFile类从多个文件的存档中使用文件名解压缩文件。如何获取要传递给ZipFile构造函数的zip文件名和目录字符串?您可以使用AssetManager和ZipInputStream 如果zip文件位于assets目录中,那么路径名是什么?将其复制到应用程序文件目录是我的最佳选择吗?APK已经是压缩的ZIP存档。把一个拉链放在APK里面是浪费时间——只要把APK的内容放进去就行了。 ZipInputStream in = null; try { final String z
ZipFile
类从多个文件的存档中使用文件名解压缩文件。如何获取要传递给ZipFile
构造函数的zip文件名和目录字符串?您可以使用AssetManager和ZipInputStream
如果zip文件位于assets目录中,那么路径名是什么?将其复制到应用程序文件目录是我的最佳选择吗?APK已经是压缩的ZIP存档。把一个拉链放在APK里面是浪费时间——只要把APK的内容放进去就行了。
ZipInputStream in = null;
try {
final String zipPath = "data/sample.zip";
// Context.getAssets()
in = new ZipInputStream(getAssets().open(zipPath));
for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) {
// handle the zip entry
}
} catch (IOException e) {
Log.e(TAG, e.getMessage());
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ignored) {
}
in = null;
}