解压函数:
/**
* 解压assert中的文件到指定目录
* @param is 文件输入流
* @param dir 目标路径(路径已存在)
* @throws IOException
*/
private void unzip (InputStream is, String dir) throws IOException
{
File dest = new File(dir);
if ( !dest.isDirectory())
throw new IOException("Invalid Unzip destination " + dest);
if(null == is){
throw new IOException("InputStream is null");
}
ZipInputStream zip = new ZipInputStream(is);
ZipEntry ze;
while ( (ze = zip.getNextEntry()) != null ) {
final String path = dest.getAbsolutePath()
+ File.separator + ze.getName();
// Create any entry folders
String zeName = ze.getName();
char cTail

这篇博客讲述了如何在Android环境下将assets目录中的zip压缩文件解压到指定目录,强调了解压过程中创建文件路径的重要性及添加写文件权限的注意事项。
最低0.47元/天 解锁文章
2598

被折叠的 条评论
为什么被折叠?



