ziputils-compression Tool Class

Source: Internet
Author: User

ziputils-compression Tool Class

Supports the Chinese decompression tool class.

Updated at: 2015-08-10

ImportOrg.apache.tools.zip.ZipEntry;ImportOrg.apache.tools.zip.ZipFile;ImportJava.io.BufferedInputStream;ImportJava.io.BufferedOutputStream;ImportJava.io.File;ImportJava.io.FileOutputStream;ImportJava.io.IOException;ImportJava.util.Enumeration; Public  class ziputils {    /** * Unzip the ZIP package to support Chinese. * Need Ant.jar Package,: http://download.csdn.net/detail/qiantujava/8984345 * * @param ZipFile need to unzip the file, such as:/MNT/SDC Ard/abc/abc.zip * @param zipfiledir the folder where the files need to be unzipped, such as:/mnt/sdcard/abc/* @throws IOException * /     Public Static void Unzipfile(String ZipFile, String zipfiledir)throwsIOException {bufferedinputstream bi; ZipFile ZF =NewZipFile (ZipFile,"GBK"); Enumeration E = Zf.getentries (); while(E.hasmoreelements ())            {ZipEntry entry = (zipentry) e.nextelement ();            String entryName = Entry.getname (); String Path = Zipfiledir +"/"+ EntryName;if(Entry.isdirectory ()) {File dir =NewFile (path);if(!dir.exists ()) dir.mkdirs (); }Else{String Filedir = path.substring (0, Path.lastindexof ("/")); File Filedirfile =NewFile (Filedir);if(!filedirfile.exists ()) filedirfile.mkdirs (); Bufferedoutputstream BOS =NewBufferedoutputstream (NewFileOutputStream (Zipfiledir +"/"+ entryName)); BI =NewBufferedinputstream (Zf.getinputstream (entry));byte[] ReadContent =New byte[1024x768];intReadcount = Bi.read (readcontent); while(Readcount! =-1) {Bos.write (readcontent,0, Readcount);                Readcount = Bi.read (readcontent);            } bos.close ();    }} zf.close (); }}

Copyright NOTICE: This article for Bo Master original article, reprint please indicate the original address.

ziputils-compression Tool Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.