本文旨在整理個人工作總結(jié),僅供參考
直接貼代碼,java代碼如下:
import java.io.IOException;import java.io.InputStream;import java.util.PRoperties;/** * @ClassName: WordPropertyUtil * @Description: 讀取配置文件 * @author sly.shuai * @date2017年2月22日 上午10:20:20 * @version V1.0 */@SuppressWarnings("serial")public class WordPropertyUtil extends Properties{ private static WordPropertyUtil instance; // 讀取配置文件 private WordPropertyUtil() { InputStream iss = null; try { iss = this.getClass().getResourceAsStream("/wordTemplate.properties"); this.load(iss); } catch (IOException e) { } finally { if (iss != null) { try { iss.close(); } catch (IOException e) { } } } } // 單例模式 public static WordPropertyUtil getInstance() { if (instance != null) { return instance; } else { instance = new WordPropertyUtil(); return instance; } }}配置文件wordTemplate.properties內(nèi)容如下:
#word導(dǎo)出模板參數(shù)配置#銀行簽收單模板存儲位置templatePath = /sly_files_server/word/templatePath/#銀行簽收單模板名字templateName = test.ftl#生成word的存儲位置filePath = /sly_files_server/word/filePath/#生成word的名字fileName = test.doc具體調(diào)用方式如下:
String templatePath = WordPropertyUtil.getInstance().getProperty("templatePath");String templateName = WordPropertyUtil.getInstance().getProperty("templateName");String filePath = WordPropertyUtil.getInstance().getProperty("filePath");String fileName = WordPropertyUtil.getInstance().getProperty("fileName");新聞熱點(diǎn)
疑難解答