當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。