public static void copyFile(
File sourceFile, File destinationDir, String destinationFileName,
Map<String, String> filterMap, boolean overwrite,
boolean preserveLastModified) {
Copy copy = new Copy();
copy.setFile(sourceFile);
copy.setFiltering(true);
copy.setOverwrite(overwrite);
copy.setPreserveLastModified(preserveLastModified);
copy.setProject(AntUtil.getProject());
if (destinationFileName == null) {
copy.setTodir(destinationDir);
}
else {
copy.setTofile(new File(destinationDir, destinationFileName));
}
if (filterMap != null) {
FilterSet filterSet = copy.createFilterSet();
for (Map.Entry<String, String> entry : filterMap.entrySet()) {
String token = entry.getKey();
String replacement = entry.getValue();
filterSet.addFilter(token, replacement);
}
}
copy.execute();
}