A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

第二个参数是对列表参数的描述,可以给值,也可以给null,面试题可能是涉及到

package com.heima.otherio;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
                                                                                                                                             
public class Demo10_Properties {
        /**
         * @param args
         * Properties是Hashtable的子类
         * @throws IOException
         * @throws FileNotFoundException
         */
        public static void main(String[] args) throws FileNotFoundException, IOException {       
                Properties prop = new Properties();
                prop.load(new FileInputStream("config.properties"));                //将文件上的键值对读取到集合中
                prop.setProperty("tel", "18912345678");//修改tel属性的值,但是此时只是改的内存中的数据
                prop.store(new FileOutputStream("config.properties"), null);//第二个参数是对列表参数的描述,可以给值,也可以给null
                System.out.println(prop);
        }       
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马