您的位置:首页 > 编程语言 > Java开发

java 读取配置文件(1)(.properties后缀)

2016-06-28 16:41 483 查看
方法一:

Properties prop = new Properties();//属性集合对象
FileInputStream fis = new FileInputStream("D:\\db.properties");//属性文件流
prop.load(fis);//将属性文件流装载到Properties对象中
String DB_URL= prop.getProperty("oracleurl");
String DB_DRIVER=prop.getProperty("oracledriver");
String DB_USERNAME=prop.getProperty("oracleuser");
String DB_PASSWORD=prop.getProperty("oraclepassword");


方法二:

ResourceBundle bundle = ResourceBundle.getBundle("payment");//读取payment.properties
String  securityUtilPrivateKey = bundle.getString("securityUtilPrivateKey")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: