`

java类中读取资源文件

    博客分类:
  • java
阅读更多
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));
     }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics