【加载读取Properties】关于Properties文件的读取
来源:互联网 发布:知乎评价章泽天长相 编辑:程序博客网 时间:2024/05/19 16:34
java中关于Properties文件的加载和读取
使用ResourceBundle类进行读取:(以jdbc.properties文件为例)
注意两种方法都不需要写文件的后缀名(.properties)
1、Properties文件位于src目录下
直接
ResourceBundle bundle = ResourceBundle.getBundle("jdbc1");
String driverClass=bundle.getString("driverClass");
2、Properties文件位于src下的com.itheima.a_jdbc.a_hello包下
ResourceBundle bundle = ResourceBundle.getBundle("com/itheima/a_jdbc/a_hello/jdbc");
String driverClass=bundle.getString("driverClass");
package com.itheima.a_jdbc.a_hello;import java.util.ResourceBundle;public class LoadProperties {public static void main(String[] args) {ResourceBundle bundle = ResourceBundle.getBundle("com/itheima/a_jdbc/a_hello/jdbc1");String driverClass=bundle.getString("driverClass");String url=bundle.getString("url");System.out.println(driverClass);System.out.println(url);}}
0 0
- 【加载读取Properties】关于Properties文件的读取
- 关于properties文件的读取
- 关于properties文件读取
- Properties读取properties文件
- Properties 读取 Properties文件
- properties 文件的读取
- properties文件的读取
- Properties文件的读取
- Properties文件的读取。
- properties文件的读取
- properties文件的读取
- spring读取加载properties文件
- Properties文件读取 Message.properties
- 读取properties文件的例子.
- 读取properties文件的方法
- properties文件的读取方式
- 读取Properties文件的方法
- 读取properties文件的方式
- [几何] BZOJ 4814 [Cqoi2017]小Q的草稿
- 在基于springboot构建的maven工程中使用mybatis框架
- zoj3953贪心
- 模板方法模式(Template Method Pattern,类行为型模式)
- 插件描述:fancyBox是一款优秀的弹出框Jquery插件。
- 【加载读取Properties】关于Properties文件的读取
- jQuery属性操作
- Java虚拟机初识
- 界面控件之——TextView的属性与应用
- TI OSAL解析
- ZOJ3956背包
- javaSE_8系列博客——Java语言的特性(二)--高级语言的基础知识(1)-- 变量
- as3加密DES过程中,1、字符串转成ByteArray(byte数组)形式 ,2、ByteArray编码成base64 3、把ByteArray转换为16进制的形式的字符串
- linux平台下防火墙iptables原理