import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties; public class PropertiesTest { public static Properties getConf(String filename){
Properties prop = new Properties(); try {
//prop.load(PropertiesTest.class.getClassLoader().getResourceAsStream("config.properties")); //放在bin/下
prop.load(new FileInputStream(filename)); //放在项目根目录
/*System.out.println(prop.getProperty("database"));
System.out.println(prop.getProperty("dbuser"));
System.out.println(prop.getProperty("dbpassword"));*/
} catch(IOException e) {
e.printStackTrace();
}
return prop;
} public static void main(String[] args) {
Properties prop = getConf("config.properties");
} }

最新文章

  1. shell日期的应用
  2. 如何在dede栏目设置中添加自定义字段(dede二次开发-纯抄贴)
  3. 调用MYSQL存储过程实例
  4. java常用包
  5. (原)ubuntu16重装显卡驱动后,torch中的问题
  6. lisp构造表
  7. ios9 之后 配置百度地图出现的错误
  8. spring 注解配置
  9. 事件的preventDefault方法
  10. php.ini 中文详解
  11. VB代码收集
  12. springboot整合ActiveMQ,配置问题
  13. DevExpress v18.2版本亮点——Reporting篇(三)
  14. ImportError: No module named 'xml'
  15. AI大牛阿里VP贾扬清
  16. hiberate 配置相关
  17. Python 网络请求模块 urllib 、requests
  18. Windows和Linux下通用的线程接口
  19. ROS 禁止公网暴力破解SSH FTP
  20. DB数据源之SpringBoot+MyBatis踏坑过程(五)手动使用Hikari连接池

热门文章

  1. ICPC World Finals 2018 Problem H Single Cut of Failure
  2. bootstrap之常见组件应用1
  3. 【02】 Vue 之 数据绑定
  4. Static 静态内部类
  5. Bzoj2882 工艺 [线性算法]
  6. [Codeforces Round #351 Div. 2] 673A Bear and Game
  7. 【BZOJ4481&JSOI2015】非诚勿扰(数学期望)
  8. CF 148D Bag of mice【概率DP】
  9. jsp和java获取文件或路径
  10. [转]在Storyboard中使用自定义的segue类型