首页 > 代码库 > 读取Properties键值对

读取Properties键值对

public class CommonFunc {

/**
* 取properties文件中的键值对
*/
public static String getProperties(String param) throws Exception {

Properties prop = new Properties();
InputStream in = Object.class.getResourceAsStream("/jdbc.properties");
try {
prop.load(in);
return prop.getProperty(param).trim();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}

}

 

技术分享

 

读取Properties键值对