java类中读取资源文件

来源:互联网 发布:求解有约束最优化问题 编辑:程序博客网 时间:2024/05/07 20:41
1:先将资源文件实例化
第一步:InputStream input=class类名.class.getResourceAsStream(url);
第二步:创建一个Properties pro=new Properties();
第三步:pro.load(input);
2:读取数据
Enumeration e=pro.propertyNames();
while(e.hasMoreElements()){
String temp=(String)e.nextElement();
System.out.print (“name=”+temp+"value"+pro.getProperty(temp));
原创粉丝点击