- package cn.com.base.common;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Properties;
- /**
- * 读取properties配置文件
- * @author using
- */
- public class Env extends Properties {
- private static Env instance;
- public static Env getInstance () {
- if(null != instance) {
- return instance;
- } else {
- makeInstance();
- return instance;
- }
- }
- private static synchronized void makeInstance() {
- if(instance == null) {
- instance = new Env();
- }
- }
- private Env() {
- InputStream is = getClass().getResourceAsStream("/global.properties");
- try {
- load(is);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/241020136673.html
来源: http://www.codesnippet.cn/detail/241020136673.html