`
Jameswsz
  • 浏览: 158038 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Java读取Properties文件

    博客分类:
  • Java
 
阅读更多
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * properties文件操作类
 *
 * @author wsz
 * @createTime 2012-4-12
 * @version 1.0
 */
public class PropertiesUtil {
	
	private static Properties properties = new Properties();
	private static InputStream inputStream = PropertiesUtil.class.getResourceAsStream("/sourceSystem.properties");
	
	/**
	 * 通过key获取对应的value
	 * 
	 * @param key
	 * @return
	 */
    public static String getSourceSystemValue(String key) {
		try {
			properties.load(inputStream);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return properties.getProperty(key);
    }

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics