PropertiesTest
2024-09-08 07:56:10
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");
} }
最新文章
- shell日期的应用
- 如何在dede栏目设置中添加自定义字段(dede二次开发-纯抄贴)
- 调用MYSQL存储过程实例
- java常用包
- (原)ubuntu16重装显卡驱动后,torch中的问题
- lisp构造表
- ios9 之后 配置百度地图出现的错误
- spring 注解配置
- 事件的preventDefault方法
- php.ini 中文详解
- VB代码收集
- springboot整合ActiveMQ,配置问题
- DevExpress v18.2版本亮点——Reporting篇(三)
- ImportError: No module named 'xml'
- AI大牛阿里VP贾扬清
- hiberate 配置相关
- Python 网络请求模块 urllib 、requests
- Windows和Linux下通用的线程接口
- ROS 禁止公网暴力破解SSH FTP
- DB数据源之SpringBoot+MyBatis踏坑过程(五)手动使用Hikari连接池
热门文章
- ICPC World Finals 2018 Problem H Single Cut of Failure
- bootstrap之常见组件应用1
- 【02】 Vue 之 数据绑定
- Static 静态内部类
- Bzoj2882 工艺 [线性算法]
- [Codeforces Round #351 Div. 2] 673A Bear and Game
- 【BZOJ4481&;JSOI2015】非诚勿扰(数学期望)
- CF 148D Bag of mice【概率DP】
- jsp和java获取文件或路径
- [转]在Storyboard中使用自定义的segue类型