File templateFile = new File(templateBase, base + template);
File templateFileInPlace = new File(templateBase, template);
if (!templateFile.exists()) {
if (!templateFileInPlace.exists()) {
throw new ConfigException("Could not find template file: " + templateFileInPlace.getAbsolutePath()
+ " for descriptor: " + descriptor.getURL());
}
if (templateFileInPlace.getAbsolutePath().equals(destFile.getAbsolutePath())) {
templateFile.getParentFile().mkdirs();
try {
StreamUtil.io(new FileInputStream(templateFileInPlace), new FileOutputStream(templateFile), true,
true);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
templateFile = templateFileInPlace;
}
} else {
template = base + template;
}
// ����destFile�ĸ�Ŀ¼
File destBase = destFile.getParentFile();
destBase.mkdirs();
if (!destBase.isDirectory()) {
throw new ConfigException("Could not create directory: " + destBase.getAbsolutePath());
}
try {
istream = new BufferedInputStream(new FileInputStream(templateFile), 8192);
ostream = new BufferedOutputStream(new FileOutputStream(destFile), 8192);
} catch (FileNotFoundException e) {
throw new ConfigException(e);
}
generator.getSession().setInputStream(istream);
generator.getSession().setOutputStream(ostream);