After more than n days, when I use the original blog article again:
Android compression and decompression zip file
When I decompressed the zip package, many problems were not found. The first is the problem of Chinese characters. The java zip package cannot solve the problem of decompression.
The judgment in getRealFileName:
If the preceding "if (dirs. length> 1)" is greater than 1, some files cannot be decompressed and changed:
If (dirs. length> 0)
If the zip package contains a Chinese directory or a Chinese file, refer to the resources on the Internet:
"Use the apache zip Toolkit (the package is ant. jar) replaces the JDK zip toolkit, because the java type does not support Chinese paths, but the two are used in the same way, but the apache compression tool has an interface for setting the encoding method, others are basically the same."
If you want to use apache in android, You need to import the ant. jar package. The download link is attached below:
Http://download.csdn.net/detail/shizhending/4139787
The following is an entry for how to add a jar package to an android project:
Http://hi.baidu.com/yore2003/item/fb6d5cd21a4bec4dddf9bef2
Note the following when adding a jar file:
Right-click the project and choose properties> Java Build Path> Order and Export.
Then place the Libray jar you just added to the top.
The following is the specific source code for using the apache zip Toolkit:
UnZipFile (String archive, String decompressDir) ZipFile zf = ZipFile (archive, "GBK" Enumeration e = ZipEntry ze2 = String entryName = String path = decompressDir + "/" + System. out. println ("creating extract directory-" + File decompressDirFile = (! } System. out. println ("creating the decompression File-" + String fileDir = path. substring (0, path. lastIndexOf ("/" File fileDirFile = (! BufferedOutputStream bos = BufferedOutputStream (FileOutputStream (decompressDir + "/" + bi = [] readContent = [1024 readCount = (readCount! =-1 bos. write (readContent, 0 readCount =}
Also remember to add permissions in AndroidManifest. xml.