All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.hutool.extra.template.AbstractTemplate Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.extra.template;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.StringWriter;
import java.util.Map;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;

/**
 * 抽象模板,提供将模板融合后写出到文件、返回字符串等方法
 *
 * @author looly
 *
 */
public abstract class AbstractTemplate implements Template{

	@Override
	public void render(Map bindingMap, File file) {
		BufferedOutputStream out = null;
		try {
			out = FileUtil.getOutputStream(file);
			this.render(bindingMap, out);
		} finally {
			IoUtil.close(out);
		}
	}

	@Override
	public String render(Map bindingMap) {
		final StringWriter writer = new StringWriter();
		render(bindingMap, writer);
		return writer.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy