This method can handle the case that the file name contains Chinese, the contents of the document contain Chinese (test environment: Win8-chinese), the code is very short, reserved for later use
Using the Ant.jar package, you need to download and import the project can be used (Org.apache.tools.ant this package is), download completed in the inside found Ant.jar package directly copied out and imported
import Java.io.file;import Org.apache.tools.ant.project;import Org.apache.tools.ant.taskdefs.expand;import Org.apache.tools.ant.taskdefs.zip;import org.apache.tools.ant.types.fileset;class ZipUtil {private static final Project Default_project = new Project (); public static void UnZip (file orgin, file dest) {Expand Expand = new Expand (); Expand.setproject (Default_project); EXPAND.SETSRC (Orgin); Expand.setdest (dest); Expand.execute (); public static void Zip (file orgin, file dest) {Zip zip = new zip (); Zip.setproject (Default_project); Zip.setdestfile (dest); Fileset fs = new Fileset (); Fs.setproject (Default_project); Fs.setdir (orgin);//Fs.setincludes ("**/*.java");//Fs.setexcludes ("**/*.xml"); Zip.addfileset (FS); Zip.execute (); }}
Using Java to implement compression/decompression (can solve Chinese garbled)