0
我正在用java寫一個自定義ant任務。我想獲得FileSet中所有文件的列表。做這個的最好方式是什麼?如何獲得Ant文件集中所有文件的列表
我正在用java寫一個自定義ant任務。我想獲得FileSet中所有文件的列表。做這個的最好方式是什麼?如何獲得Ant文件集中所有文件的列表
看一看的例子從Tutorial: Tasks using Properties, Filesets & Paths:
FileSet fs;
// ...
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] includedFiles = ds.getIncludedFiles();
for(int i=0; i<includedFiles.length; i++) {
String filename = includedFiles[i].replace('\\','/');
...
}
你可能更願意使用Union.listResources()。它返回一個Resource [],這可能更容易處理。 不幸的是,良好的文檔似乎缺乏。看看源代碼:http://svn.apache.org/repos/asf/ant/core/tags/ANT_171/src/main/org/apache/tools/ant/types/resources/Union.java 我在jslint4java中使用了這個:http://github.com/happygiraffe/jslint4java/blob/master/jslint4java-ant/src/main/java/com/googlecode/jslint4java/ant/JSLintTask.java – 2010-05-06 11:32:58