zoukankan      html  css  js  c++  java
  • Properties集合_list方法与store方法

    Properties集合和流对象结合的功能

    list()方法:

    import java.util.Properties;
    
    public class PropertiesDemo {
        public static void main(String[] args) {
            propertiesDemo();
        }
    
        public static void propertiesDemo() {
            Properties prop = new Properties();
            prop.setProperty("02", "huangjianfeng");
            prop.setProperty("03", "jianfeng");
            prop.setProperty("04", "feng");
            
            prop.list(System.out);//该方法多用于调式,开发中很少用
        }
    }

    store()方法:

    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    
    public class PropertiesDemo {
        public static void main(String[] args) throws IOException {
            propertiesDemo();
        }
    
        public static void propertiesDemo() throws IOException {
            Properties prop = new Properties();
            prop.setProperty("02", "hujianfeng");
            prop.setProperty("03", "jianfeng");
            prop.setProperty("04", "feng");
            
            //想要将这个集合中的字符串键值信息持久化存储到文件中,需要关联输出流
            FileOutputStream fos = new FileOutputStream("F:\info.txt");
            
            //将集合中的数据存储到文件中,使用store方法
            prop.store(fos, "number+name");//第二个参数表示对这个表的描述,也就是说说明这个表是什么
            fos.close(); 
        }
        
    }
  • 相关阅读:
    centos7安装jdk8
    centos7安装mysql5.7.31
    docker打包,运行springboot
    centos7安装docker
    ps学习记录
    Html的学习(二)
    tensorflow C++接口调用图像分类pb模型代码
    tensorflow C++接口调用目标检测pb模型代码
    ubuntu14 编译tensorflow C++ 接口
    Python opencv计算批量图片的BGR各自的均值
  • 原文地址:https://www.cnblogs.com/LO-ME/p/3595478.html
Copyright © 2011-2022 走看看