读取properties配置文件信息

直接上代码了,很简单。

读取resourse.properties配置文件 

读取properties配置文件
 1 import java.util.ResourceBundle;
2
3 public class LoadProperties {
4 private static ResourceBundle cache=null;
5 static{
6 cache=ResourceBundle.getBundle("resourse");
7 }
8
9 public static String getValue(String key){
10 return cache.getString(key);
11 }
12 }

测试:

Test类
1 public class Test {
2 public static void main(String[] args) {
3 System.out.println(LoadProperties.getValue("aaa"));
4 }
5 }



 

原文地址:https://www.cnblogs.com/Laupaul/p/2396493.html