1. 程式人生 > >讀配置檔案取配置引數工具類PropertiesUtil

讀配置檔案取配置引數工具類PropertiesUtil

public class PropertiesUtil {

	private static Properties properties = new Properties();

	static {
		InputStream in = PropertiesUtil.class.getResourceAsStream("/config.properties");
		try {
			properties.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

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