其他分享
首页 > 其他分享> > 04-IO-ZipInputStream解压流

04-IO-ZipInputStream解压流

作者:互联网

package bbbbbbbbbbbbb;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class APP2 {
    
    
    public static void main(String[] args) throws Exception {
        
        File zip=new File("c:/aaa.zip");
        FileInputStream in=new FileInputStream(zip);
        
        ZipInputStream zin=new ZipInputStream(in);
        
        ZipEntry entry=null;
        
        
        
         while((entry = zin.getNextEntry())!=null)
         {
             String name = entry.getName();
             File desc=new File("c:/"+name);
             FileOutputStream out=new FileOutputStream(desc);
             
             BufferedOutputStream bos=new BufferedOutputStream(out);
             
             int len=-1;
             byte[] buffer=new byte[1024];
             while((len = zin.read(buffer))!=-1)
             {
                 bos.write(buffer, 0, len);
             }
             
             bos.flush();
             bos.close();
         }
        
         in.close();
        
    }
}

 

标签:ZipInputStream,zip,java,io,04,File,IO,import,new
来源: https://www.cnblogs.com/hua900822/p/16221036.html