http://my.csdn.net/my/mycsdn

对于I/O流中解压中遇到的问题

今天早上打了一个程序,是关于解压文件的,但是在运行时程序不报错,也不提示,运行结果没有任何信息,在没有办法的情况下,用命令提示符运行了一下 ,编译没有问题,但是在运行时出现了无法找到主类或者加载主类。出现这一结果,我以为是我的类名和文件的名不符,但是在找了好几遍之后,仍然没有找出错误,并且在群里也问了一些人,也没有找出错误,对于这个问题,我想以后慢慢的深究,希望能得出答案!现在给出完整程序如下,希望看到有知道的人给我指点一下!在此表示感谢!

package com.tangdeqiang.rtbc5;

import java.io.File;
import java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class TestInputZip{

    public static void main(String[] temp){
        
        ZipInputStream zin;
        try{
            zin=new ZipInputStream(new FileInputStream("d:\\hello.zip"));
            ZipEntry entry=zin.getNextEntry();
            while(((entry=zin.getNextEntry())!=null)&&!entry.isDirectory()){
                File file=new File("d:\\"+entry.getName());
                System.out.println(file);
                if(!file.exists()){
                    file.mkdirs();
                    file.createNewFile();
                }
                zin.closeEntry();
                System.out.println(entry.getName()+"解压成功");
            }
            zin.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

}

 

posted on 2017-10-17 10:21  C知家  阅读(175)  评论(0编辑  收藏  举报

导航

http://my.csdn.net/my/mycsdn