Newer
Older
sink / src / main / java / org / flume / alarm / util / Configure.java
zhout on 2 Mar 2022 887 bytes first commit
package org.flume.alarm.util;

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

public class Configure {

	private static Properties properties = new Properties();

	static {
		try {
			ClassLoader cl = Configure.class.getClassLoader();
			InputStream is = cl.getResourceAsStream("springSensor/application.properties");
			properties.load(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

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

	public static Object setProperty(String key,String value) {
		return properties.setProperty(key,value);
	}

	public static String getProperty(String key, String defaultValue) {
		String value = properties.getProperty(key);
		if (null == value) {
			return defaultValue;
		} else {
			return value;
		}
	}

	public static void main(String[] args) {

	}

}