Properties类
来源:互联网 发布:linux查询逻辑cpu个数 编辑:程序博客网 时间:2024/05/28 06:07
mark一下
this.getClass().getClassLoader().getResourceAsStream(“properties.properties”);
加载的是src目录下的文件。
package Properties;import java.io.IOException;import java.io.InputStream;import java.util.Iterator;import java.util.Properties;public class PropertiesTest { public static void main(String[] args) throws IOException { PropertiesTest t=new PropertiesTest(); t.testProperties(); } //使用Properties类进行操作 public void testProperties() throws IOException{ //使用Properties类,读取properties文件 Properties pro = new Properties(); //获取class路径下的properties文件 InputStream in =//new FileInputStream("properties.properties") this.getClass().getClassLoader().getResourceAsStream("properties.properties"); //加载properties文件 pro.load(in); //获取键-值 Iterator<String> it=pro.stringPropertyNames().iterator(); while(it.hasNext()){ String key=it.next(); //键 System.out.println(key+":"+pro.getProperty(key));//值 } }}
0 0
- Properties 类
- 类Properties
- Properties类
- Properties类
- Properties类
- properties类
- Properties类
- Properties 类
- Properties类
- properties类
- 类 Properties
- Properties类
- Properties类
- Properties类
- Properties类
- Properties类
- Properties类
- Properties类
- 学习JavaScript(1)-制作一个简单的石头剪刀布游戏
- snake打印回字打印顺序打印及一二维vector初始化
- Request请求类的封装继承与应用
- 10倍提升应用性能的10个建议 (理论篇)
- classpath、path、JAVA_HOME的作用及JAVA环境变量配置
- Properties类
- 我做服务器的岁月8
- 关于如何管理自己
- C++,MessageBox的常见用法
- Go语言基础:Interface
- 字典序问题(排列组合)
- Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。
- samba引起的问题
- Java笔记 - final