`

Properties类使用

 
阅读更多
package com.emolay.util;

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

public class PropertiesUtils {
	
	private static final Properties properties = new Properties();
	
	static {
		try {
			load();
		} catch (Exception e) {
		}
	}
	private static void load(){
		InputStream input = null;
		try {
			input = PropertiesUtils.class.getResourceAsStream("/application.properties");
			properties.load(input);
		}  catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static String getProperty(String key){
		String value = "";
		if (properties.containsKey(key)) {
			value = properties.getProperty(key);
		}
		return value;
	}
	
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics