原文转自:http://hustcen.iteye.com/blog/736773
一个简单的打包zip包的方法?
需要需要ant.jar?? apache上可下载?
- import?java.io.File;??
- ??
- import?org.apache.tools.ant.Project;??
- import?org.apache.tools.ant.taskdefs.Zip;??
- import?org.apache.tools.ant.types.FileSet;??
- ??
- ??
- public?class?ZipTest?{??
- ??
- ????/**?
- ?????*?@param?args?
- ?????*/??
- ????public?static?void?main(String[]?args)?{??
- ?????????Project?pj?=?new?Project();??
- ?????????Zip?zip?=?new?Zip();??
- ?????????zip.setProject(pj);??
- ?????????zip.setDestFile(new?File("F:/1.zip"));//打包完的目标文件??
- ???????????
- ?????????FileSet?fileSet?=?new?FileSet();??
- ?????????fileSet.setProject(pj);??
- ?????????fileSet.setDir(new?File("F:/context"));//需要打包的路径??
- ?????????fileSet.setIncludes("*.doc");//文件过滤??只?包含所有.doc文件??
- ???????????
- ?????????zip.addFileset(fileSet);??
- ?????????zip.execute();??
- ????}??
- ??
- } ?
?
java 打包 zip ?zip 打包 ?ZIP 打包 JAVA