使用ant 压缩文件
来源:互联网 发布:淘宝看图购 编辑:程序博客网 时间:2024/05/23 01:26
/** * @param _sPath 压缩文件夹 */public static void compress(String _sPath) {logger.info("Compress The Path:" + _sPath);String sBasePath = "d:/FixPackage/";String sInDir = sBasePath + _sPath;String sOutDir = sBasePath + _sPath + ".zip";// System.out.println("sInDir:"+sInDir);// System.out.println("sOutDir:"+sOutDir);File oSrcDir = new File(sInDir);if (!oSrcDir.exists()) {throw new RuntimeException(oSrcDir + "不存在");}Project prj = new Project();Zip zip = new Zip();zip.setProject(prj);File sOut = new File(sOutDir);zip.setDestFile(sOut);FileSet oSet = new FileSet();oSet.setProject(prj);File oIn = new File(sInDir);oSet.setDir(oIn);zip.addFileset(oSet);zip.execute();}