RSS
热门关键字:  java  Ajax  JSP  Struts  JSF
当前位置 : 首页>Java>列表

java实现zip与unzip

来源: 作者: 时间:2007-08-09 点击:
            while(emu.hasMoreElements()){
                ZipEntry entry 
= (ZipEntry)emu.nextElement();
                
//会把目录作为一个file读出一次,所以只建立目录就可以,之下的文件还会被迭代到。
                if (entry.isDirectory())
                
{
                    
new File(filePath + entry.getName()).mkdirs();
                    
continue;
                }

                BufferedInputStream bis 
= new BufferedInputStream(zipFile.getInputStream(entry));
                File file 
= new File(filePath + entry.getName());
                
//加入这个的原因是zipfile读取文件是随机读取的,这就造成可能先读取一个文件
                
//而这个文件所在的目录还没有出现过,所以要建出目录来。
                File parent = file.getParentFile();
                
if(parent != null && (!parent.exists())){
                    parent.mkdirs();
                }

                FileOutputStream fos 
= new FileOutputStream(file);
                BufferedOutputStream bos 

最新评论共有 2 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
Google Adsense
相关文章