Properties是Hashtable的子类
来源:互联网 发布:淘宝怎么上传视频凭证 编辑:程序博客网 时间:2024/05/21 10:17
/**
* @param args
* Properties是Hashtable的子类
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
//demo1();
//demo2();
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties")); //将文件上的键值对读取到集合中
prop.setProperty("tel", "18912345678");
prop.store(new FileOutputStream("config.properties"), null);//第二个参数是对列表参数的描述,可以给值,也可以给null
System.out.println(prop);
}
public static void demo2() {
Properties prop = new Properties();
prop.setProperty("name", "张三");
prop.setProperty("tel", "18912345678");
//System.out.println(prop);
Enumeration<String> en = (Enumeration<String>) prop.propertyNames();
while(en.hasMoreElements()) {
String key = en.nextElement(); //获取Properties中的每一个键
String value = prop.getProperty(key); //根据键获取值
System.out.println(key + "="+ value);
}
}
public static void demo1() {
Properties prop = new Properties();
prop.put("abc", 123);
System.out.println(prop);
}
* @param args
* Properties是Hashtable的子类
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
//demo1();
//demo2();
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties")); //将文件上的键值对读取到集合中
prop.setProperty("tel", "18912345678");
prop.store(new FileOutputStream("config.properties"), null);//第二个参数是对列表参数的描述,可以给值,也可以给null
System.out.println(prop);
}
public static void demo2() {
Properties prop = new Properties();
prop.setProperty("name", "张三");
prop.setProperty("tel", "18912345678");
//System.out.println(prop);
Enumeration<String> en = (Enumeration<String>) prop.propertyNames();
while(en.hasMoreElements()) {
String key = en.nextElement(); //获取Properties中的每一个键
String value = prop.getProperty(key); //根据键获取值
System.out.println(key + "="+ value);
}
}
public static void demo1() {
Properties prop = new Properties();
prop.put("abc", 123);
System.out.println(prop);
}
阅读全文
0 0
- Properties是Hashtable的子类
- Properties是Hashtable的子类
- properties类是Hashtable的子类
- HashTable 的子类 Properties类
- Hashtable的子类Properties的使用
- properties时hashTable子类
- Properties是Hashtable的一个子类:以文件来进行存储键值对
- Properties的用法 Map映射 集合下的子类 Hashtable 的子类
- Java HashTable 以及子类 Properties使用
- HashTable,HashMap,Properties的区别
- HashTable的子類properties
- Properties子类
- java 中Map 常用的子类 之 Hashtable
- Java -- Hashtable 和 Properties
- Hashtable与Properties
- HashMap(Hashtable、properties)
- 继承了hashtable的properties的小实例
- 使用UITableViewCell子类是出现的问题
- 设置指针
- 英文版 ubuntu不能输入中文问题及解决方案
- Visual C++ for Linux Development
- AFNetworking 的核心 AFURLSessionManager(二)
- Flume研究应用
- Properties是Hashtable的子类
- POJ2175_Evacuation Plan_消负圈的“更小”费用流
- 从0开始学OpenGL之Mac篇(1)
- 定义一个文件输入流,调用read(byte[] b)方法,将a.txt文件中的内容打印出来(byte数组大小限制为5)
- Tomcat在局域网中localhost可以访问,但是无法通过本地ip访问,127.0.0.1也无法访问问题的解决方法
- 改变标准输入输出流
- 得到-薛兆丰的北大经济学课-1-人性与稀缺
- 面试心得与总结---BAT、网易、蘑菇街
- CC3200 Simplelink Wi-Fi 入门指南