我想使用ZipFile类从多个文件的存档中使用其名称解压缩文件.如何获取要传递给ZipFile构造函数的zip文件名和目录的字符串?
解决方法:
您可以使用AssetManager和ZipInputStream
http://developer.android.com/reference/android/content/res/AssetManager.html
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;
}