本文整理汇总了Java中org.jbake.app.FileUtil类的典型用法代码示例。如果您正苦于以下问题:Java FileUtil类的具体用法?Java FileUtil怎么用?Java FileUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileUtil类属于org.jbake.app包,在下文中一共展示了FileUtil类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initStructure
import org.jbake.app.FileUtil; //导入依赖的package包/类
private void initStructure(CompositeConfiguration config, String type, String source) {
Init init = new Init(config);
try {
File templateFolder = FileUtil.getRunningLocation();
File outputFolder;
if(source != null){
outputFolder = new File(source);
} else{
outputFolder = new File(".");
}
init.run(outputFolder, templateFolder, type);
System.out.println("Base folder structure successfully created.");
} catch (final Exception e) {
final String msg = "Failed to initialise structure: " + e.getMessage();
throw new JBakeException(msg, e);
}
}
示例2: ensureSource
import org.jbake.app.FileUtil; //导入依赖的package包/类
private void ensureSource() {
if (!FileUtil.isExistingFolder(source)) {
throw new JBakeException("Error: Source folder must exist: " + source.getAbsolutePath());
}
if (!source.canRead()) {
throw new JBakeException("Error: Source folder is not readable: " + source.getAbsolutePath());
}
}
示例3: setupRequiredFolderFromConfig
import org.jbake.app.FileUtil; //导入依赖的package包/类
private File setupRequiredFolderFromConfig(final String key) {
final File path = setupPathFromConfig(key);
if (!FileUtil.isExistingFolder(path)) {
throw new JBakeException("Error: Required folder cannot be found! Expected to find [" + key + "] at: " + path.getAbsolutePath());
}
return path;
}
示例4: renderDocument
import org.jbake.app.FileUtil; //导入依赖的package包/类
@Override
public void renderDocument(final Map<String, Object> model, String templateName, final Writer writer) throws RenderingException {
model.put("version", config.getString(Keys.VERSION));
Map<String, Object> configModel = new HashMap<String, Object>();
Iterator<String> configKeys = config.getKeys();
while (configKeys.hasNext()) {
String key = configKeys.next();
//replace "." in key so you can use dot notation in templates
configModel.put(key.replace(".", "_"), config.getProperty(key));
}
model.put("config", configModel);
// if default template exists we will use it
File templateFile = new File(templatesPath, templateName);
if (!templateFile.exists()) {
LOGGER.info("Default template: {} was not found, searching for others...", templateName);
// if default template does not exist then check if any alternative engine templates exist
String templateNameWithoutExt = templateName.substring(0, templateName.length() - 4);
for (String extension : renderers.getRecognizedExtensions()) {
templateFile = new File(templatesPath, templateNameWithoutExt + "." + extension);
if (templateFile.exists()) {
LOGGER.info("Found alternative template file: {} using this instead", templateFile.getName());
templateName = templateFile.getName();
break;
}
}
}
String ext = FileUtil.fileExt(templateName);
AbstractTemplateEngine engine = renderers.getEngine(ext);
if (engine != null) {
engine.renderDocument(model, templateName, writer);
} else {
LOGGER.error("Warning - No template engine found for template: {}", templateName);
}
}