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();
} }

Properties集合_list方法与store方法的更多相关文章

  1. Properties集合中的方法store和Properties集合中的方法load

    Properties集合中的方法store public class Demo01Properties { public static void main(String[] args) throws ...

  2. 使用Properties集合存储数据,遍历取出Properties集合中的数据和Properties集合中的方法store和load

    package com.yang.Test.PropertiesStudy; import java.io.FileWriter; import java.io.IOException; import ...

  3. java的缓冲流及使用Properties集合存取数据(遍历,store,load)

    缓冲流 概述 字节缓冲流:BufferedInputStream,BufferedOutputStream 字符缓冲流:BufferedReader,BufferedWriter 缓冲流原理 缓冲区是 ...

  4. C#中对象,字符串,dataTable、DataReader、DataSet,对象集合转换成Json字符串方法。

    C#中对象,字符串,dataTable.DataReader.DataSet,对象集合转换成Json字符串方法. public class ConvertJson { #region 私有方法 /// ...

  5. Collection中list集合的应用常见的方法

    集合 : 用存放对象的容器(集合)     Collection : 跟接口 : 单列集合          ---> List :有序的 ,元素是可以重复的.          ---> ...

  6. Map集合遍历的2种方法

    Map是一个集合的接口,是key-value相映射的集合接口,集合遍历的话,需要通过Iterator迭代器来进行. Iterator是什么东西: java.util包下的一个接口: 对 collect ...

  7. 安装PHP过程中,make步骤报错:(集合网络上各种解决方法)

    安装PHP过程中,make步骤报错:(集合网络上各种解决方法) (1)-liconv -o sapi/fpm/php-fpm /usr/bin/ld: cannot find -liconv coll ...

  8. JAVA8 Stream集合操作:中间方法和完结方法

    StreamLambda为java8带了闭包,这一特性在集合操作中尤为重要:java8中支持对集合对象的stream进行函数式操作,此外,stream api也被集成进了collection api, ...

  9. 从集合中查找最值得方法——max(),min(),nlargest(),nsmallest()

    从集合中查找最值得方法有很多,常用的方法有max(),min(),nlargest(),nsmallest()等. 一.max()和min() 1.1 入门用法 直接使用max(),min(),返回可 ...

随机推荐

  1. synchronized锁住的是代码还是对象

    不同的对象 public class Sync { public synchronized void test() { System.out.println("test start" ...

  2. jquery根据name属性查找元素

    $("div[id]") //选择所有含有id属性的div元素 $("input[name='newsletter']") //选择所有的name属性等于'ne ...

  3. jquery实现点击文字后变成文本框且可修改

    $(function() { //获取class为caname的元素 $(".caname").click(function() { var td = $(this); var t ...

  4. React Native顶|底部导航使用小技巧

    导航一直是App开发中比较重要的一个组件,ReactNative提供了两种导航组件供我们使用,分别是:NavigatorIOS和Navigator,但是前者只能用于iOS平台,后者在ReactNati ...

  5. Linux ELF 文件格式

    ELF 文件类型 ELF (Executable Linkable Format) 是 linux 下的可执行文件格式,与 windows 下的 PE (Portable Executable) 格式 ...

  6. Spring MVC 学习总结(十)——Spring+Spring MVC+MyBatis框架集成(IntelliJ IDEA SSM集成)

    与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC负责请求的转发和 ...

  7. 搜藏一个php文件上传类

    <?php /** * 上传文件类 * @param _path : 服务器文件存放路径 * @param _allowType : 允许上传的文件类型和所对应的MIME * @param _f ...

  8. Install/Remove of the Service Denied!

    在windos 的cmd下安装mysql 在mysql的bin目录下面执行: mysqld --install 报错: 信息如下一: Install/Remove of the Service Den ...

  9. Intellij Idea乱码解决方案

    使用Intellij Idea经常遇到的三种乱码问题: 1.工程代码乱码 2.main方法运行,控制台乱码 3.tomcat运行,控制台乱码 解决方案: 1.工程代码乱码 Settings > ...

  10. 【转】Git 教程之协同开发

    前面我们已经介绍过远程仓库的相关概念,不过那时并没有深入探讨,只是讲解了如何创建远程仓库以及推送最新工作成果到远程仓库,实际上远程仓库对于团队协同开发很重要,不仅仅是团队协同开发的基础,也是代码备份的 ...