Java获取properties配置文件信息
2015-11-25 09:56
706 查看
调用方法:String url = PropertiesUtil.getProperty("url");
public class PropertiesUtil { public static Properties property; static { property = new Properties(); InputStream in = PropertiesUtil.class.getResourceAsStream("/init.properties"); try { property.load(in); } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } public static String getProperty(String key) { return property.getProperty(key); } }
相关文章推荐
- 听说大家使用Eclipse写Servlet的时候总会遇到404
- struts2 标签里面不能使用el表达式可以使用ongl表达式
- [转]关于java中的 sychronized 同步方法 与 同步块的理解
- java判断字符串是否为空的常用方法
- Android 如何在Eclipse中查看Android API源码以及support包源码(转载)
- spring配置文件的加载
- Java 中无参带返回值方法的使用
- Java线程详解
- eclipse 的Ctrl 键失效
- java如何生成二维码图片
- JDK 动态代理
- Eclipse问题(The project was not built since its build path is incomplete)
- Java intern
- SpringMVC返回页面数据
- Java 中的二维数组
- spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件)
- java位运算应用
- SpringMVC参数传递
- IntelliJ IDEA启动不了 legacy Java SE 6 runtime.
- 【Maven】使用eclipse maven创建一个web project