PatternSets are used to select files to extract from the archive, if no patternset is used, all files are extracted.
File permissions will not be restored on extracted files
Please note that different ZIP tools handle timestamps differently when it comes to applying timezone offset calculations of files. Some ZIP libraries will store the timestamps as they've been read from the filesystem while others will modify the timestamps both when reading and writing the files to make all timestamps use the same timezone. A ZIP archive created by one library may extract files with "wrong timestamps" when extracted by another library
public 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();
}
/**
* @param args
*/
public static void main(String[] args) {
File orgin = new File("f:\\PID_3C99008722CF3A4DC8EBE8FAA267FDE9F11E.zip");
File dest = new File("f:\\unzip\\");
unZip(orgin, dest);
System.out.println("----------un zip -----------");
File zip = new File("f:\\zip\\test.zip");
System.out.println("----------zip starting-----------");
zip(dest, zip);
System.out.println("----------zip success-----------");
}
}