里面的src是一个制定要拷贝的文件列表
<?xml version="1.0" encoding="UTF-8"?>
<project name="TestCopy" basedir="." default="copyFile">
<property name="src" value="list.txt"/>
<property name="dest" value="D:/archive"/>
<property name="src_dir" value="D:/Workspace"/>
<target name="copyFile">
<script language="javascript"> <![CDATA[
importClass(java.io.FileReader);
importClass(java.io.BufferedReader);
importClass(java.util.ArrayList);
importClass(java.io.File);
// Access to Ant-Properties by their names
src = TestCopy.getProperty("src");
dest = TestCopy.getProperty("dest");
src_dir = TestCopy.getProperty("src_dir");
// Get the the change files list
var br = new BufferedReader(new FileReader(src));
var arrayList = new ArrayList();
var line="";
while((line = br.readLine()) != null){
arrayList.add(line);
}
// iterate that array
for ( i=1; i< arrayList.size(); i++) {
//copy the specify file
copy = TestCopy.createTask("copy");
var srcFile = new File(src_dir+arrayList.get(i));
copy.setFile(srcFile);
//dest file
var destDir = dest + arrayList.get(i);
var destFile = new File(destDir);
copy.setTofile(destFile);
copy.setVerbose(true);
copy.setOverwrite(true);
copy.perform();
}
]]></script>
</target>
</project>
posted on 2011-04-06 23:29
fly 阅读(346)
评论(0) 编辑 收藏 所属分类:
工作日志