首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ZIP资料解压缩

2012-10-07 
ZIP文件解压缩public void unZip(File file, String unzipFolder) throws IOException {byte b[] new by

ZIP文件解压缩

public void unZip(File file, String unzipFolder) throws IOException {byte b[] = new byte[2048];int length;ZipFile zipFile = new ZipFile(file, "MS932");@SuppressWarnings("rawtypes")Enumeration enumeration = zipFile.getEntries();ZipEntry zipEntry = null;OutputStream outputStream = null;InputStream inputStream = null;while (enumeration.hasMoreElements()) {zipEntry = (ZipEntry) enumeration.nextElement();File loadFile = new File(unzipFolder + zipEntry.getName());if (zipEntry.isDirectory()) {loadFile.mkdirs();} else {if (!loadFile.getParentFile().exists())loadFile.getParentFile().mkdirs();outputStream = new FileOutputStream(loadFile);inputStream = zipFile.getInputStream(zipEntry);/* 写入文件 */while ((length = inputStream.read(b)) > 0) {outputStream.write(b, 0, length);}}}outputStream.close();inputStream.close();zipFile.close(); }
?

?

热点排行