当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:18,代码来源:Main.java

示例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());
    }
}
 
开发者ID:netdava,项目名称:jbakery,代码行数:9,代码来源:Oven.java

示例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;
}
 
开发者ID:netdava,项目名称:jbakery,代码行数:8,代码来源:Oven.java

示例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);
    }
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:35,代码来源:DelegatingTemplateEngine.java


注:本文中的org.jbake.app.FileUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。