国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

使用單例讀取配置文件

2019-11-06 06:13:30
字體:
供稿:網(wǎng)友

本文旨在整理個人工作總結(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");
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 乌鲁木齐市| 余姚市| 花垣县| 拜城县| 二连浩特市| 汉阴县| 德安县| 武川县| 抚远县| 丰镇市| 安丘市| 安塞县| 玉林市| 锡林郭勒盟| 南郑县| 建平县| 开江县| 图片| 阜南县| 资兴市| 舟曲县| 台湾省| 张北县| 博野县| 宝兴县| 海宁市| 富阳市| 航空| 通渭县| 崇左市| 莱芜市| 措美县| 莱西市| 凉山| 鹤壁市| 甘泉县| 凤翔县| 珲春市| 谷城县| 渝中区| 尉氏县|