对zip压缩包进行解压



public static Map unZipFile(String path, String zipFileName) throws IOException{

        
        ZipEntry entry = null;  
        FileInputStream fis = new FileInputStream(path+zipFileName);   
        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));  
        BufferedInputStream bin=new BufferedInputStream(zis);
        
        Map fileMap = new HashMap();
        while((entry = zis.getNextEntry())!=null && !entry.isDirectory()){
            File file = new File(path, entry.getName());
            FileOutputStream out=new FileOutputStream(file);  
            BufferedOutputStream bout=new BufferedOutputStream(out);  
            int b;  
            while((b=bin.read())!=-1){  
                bout.write(b);  
            }  
            bout.close();  
            out.close();  
            
            fileMap.put(entry.getName(), file);
        }
        
        zis.close();
        fis.close();
        
        return fileMap;
    }

你可能感兴趣的:(JAVA进阶--基础查缺补漏)