Riordon

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

package com.glsx.conf;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigurationManager {
private static Properties prop = new Properties();
static {
InputStream inputStream = ConfigurationManager.class.getClassLoader().getResourceAsStream("conf/my.properties");
try {
prop.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}

public static String getString(String key) { return prop.getProperty(key); }

public static Integer getInteger(String key) { return Integer.valueOf(prop.getProperty(key)); }

public static Boolean getBoolean(String key) {
    return Boolean.valueOf(prop.getProperty(key));
}

public static Long getLong(String key) {
    return Long.valueOf(prop.getProperty(key));
}

public static Double getDouble(String key) {
    return Double.valueOf(prop.getProperty(key));
}

public static void main(String[] args) {
    System.out.println(ConfigurationManager.getString("hbase.zookeeper.quorum"));
}

}

posted on 2019-11-12 07:17  Riordon  阅读(95)  评论(0编辑  收藏  举报