Android解压Zip包
来源:互联网 发布:java运算符有哪些 编辑:程序博客网 时间:2024/04/27 20:06
/**
* 解压一个压缩文档 到指定位置
*
* @param zipFileString 压缩包的名字
* @param outPathString 指定的路径
* @throws Exception
*/
public static void UnZipFolder(String zipFileString, String outPathString) throws Exception {
java.util.zip.ZipInputStream inZip = new java.util.zip.ZipInputStream(new java.io.FileInputStream(zipFileString));
java.util.zip.ZipEntry zipEntry;
String szName = "";
while ((zipEntry = inZip.getNextEntry()) != null) {
szName = zipEntry.getName();
if (zipEntry.isDirectory()) {
// get the folder name of the widget
szName = szName.substring(0, szName.length() - 1);
java.io.File folder = new java.io.File(outPathString + java.io.File.separator + szName);
folder.mkdirs();
} else {
java.io.File file = new java.io.File(outPathString + java.io.File.separator + szName);
file.createNewFile();
// get the output stream of the file
java.io.FileOutputStream out = new java.io.FileOutputStream(file);
int len;
byte[] buffer = new byte[1024];
// read (len) bytes into buffer
while ((len = inZip.read(buffer)) != -1) {
// write (len) byte from buffer at the position 0
out.write(buffer, 0, len);
out.flush();
}
out.close();
}
}//end of while
inZip.close();
}//end of func
* 解压一个压缩文档 到指定位置
*
* @param zipFileString 压缩包的名字
* @param outPathString 指定的路径
* @throws Exception
*/
public static void UnZipFolder(String zipFileString, String outPathString) throws Exception {
java.util.zip.ZipInputStream inZip = new java.util.zip.ZipInputStream(new java.io.FileInputStream(zipFileString));
java.util.zip.ZipEntry zipEntry;
String szName = "";
while ((zipEntry = inZip.getNextEntry()) != null) {
szName = zipEntry.getName();
if (zipEntry.isDirectory()) {
// get the folder name of the widget
szName = szName.substring(0, szName.length() - 1);
java.io.File folder = new java.io.File(outPathString + java.io.File.separator + szName);
folder.mkdirs();
} else {
java.io.File file = new java.io.File(outPathString + java.io.File.separator + szName);
file.createNewFile();
// get the output stream of the file
java.io.FileOutputStream out = new java.io.FileOutputStream(file);
int len;
byte[] buffer = new byte[1024];
// read (len) bytes into buffer
while ((len = inZip.read(buffer)) != -1) {
// write (len) byte from buffer at the position 0
out.write(buffer, 0, len);
out.flush();
}
out.close();
}
}//end of while
inZip.close();
}//end of func
0 0
- Android解压Zip包
- android解压ZIP压缩包文件
- android解压带密码的zip包
- android解压zip格式包的方法
- android解压zip格式的包
- Android 不解压直接读取zip包
- java解压zip包
- unity3d解压zip包
- java 解压zip包
- jar命令解压zip包
- 解压zip压缩包(JAVA)
- linux zip包压缩 解压
- java解压Zip压缩包
- java解压zip压缩包
- Android zip解压
- Android 解压zip文件
- android zip解压
- android解压ZIP文件
- WebView保留缩放功能但隐藏缩放控件
- 在Windows系统下安装、配置Tomcat
- Android获取网络类型名称
- 为iOS项目添加Daily Build
- poj 1458 Common Subsequence(最长公共子序列)
- Android解压Zip包
- XCode编译出错问题整理
- linux下apache+tomcat负载均衡和集群
- Android从assets中读取文本和图片资源
- BroadcastReceiver学习例程
- Windows安装easy_install出错: 'ascii' codec can't decode byte
- OC中类的三大特性:封装、继承和多态
- 建筑与软件
- hiho 第二十三周 Dijkstra