java加载.properties文件

--类加载.properties文件的方法

InputStream in = class(class加载文件的类名).class.getClassLoader().getResourceAsStream("a.properties");

--用Iterator读取.properties文件内容

Properties p=new Properties();

InputStream in = class(class加载文件的类名).class.getClassLoader().getResourceAsStream("a.properties");

p.load(in);

Iterator<String> its=p.stringPropertyNames().iterator();

while (its.hasNext()) {

System.out.println(its.next());

}

 
 

 
 


 

猜你喜欢

转载自blog.csdn.net/weixin_38723919/article/details/79041473
今日推荐