读取zip,不过滤中文名,即中文名称也能成功读取 分类: java 20091106 22:48 296人阅读 评论(0) 收藏 import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import org.apache.tools.zip.ZipEntry; import org.apache.tools.zip.ZipFile; public class T3 { public static void main(String[] args) { try { ZipFile zfile = new ZipFile("e://mobile.zip"); Enumeration zList = zfile.getEntries(); byte[] buf = new byte[1024]; while (zList.hasMoreElements()) { ZipEntry ze = (ZipEntry) zList.nextElement(); if (ze.isDirectory()) { continue; } String icon_name = ze.getName(); // 以ZipEntry为参数得到一个InputStream,并写到OutputStream中 OutputStream os = new BufferedOutputStream(new FileOutputStream("e://zhong//"+icon_name)); InputStream is = new BufferedInputStream(zfile.getInputStream(ze)); int readLen = 0; while ((readLen = is.read(buf)) != -1) { os.write(buf, 0, readLen); } os.close(); is.close(); System.out.println("end ...."); } zfile.close(); }catch(Exception e){ e.printStackTrace(); } } } 版权声明:本文为博主原创文章,未经博主允许不得转载。