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. 基于 CGLIB 库的动态代理机制

    之前的文章我们详细的介绍了 JDK 自身的 API 所提供的一种动态代理的实现,它的实现相对而言是简单的,但是却有一个非常致命性的缺陷,就是只能为接口中的方法完成代理,而委托类自己的方法或者父类中的方 ...

  2. Spring @Pathvariable

    先记录下@PathVariable的用法吧: @RequestMapping("/demo/{id}") @ResponseBody public User getUser(@Pa ...

  3. VS2017进程为idXXXX 无法启动解决方案

    1.对无法启动项目的 .csproj 后缀文件用记事本打开 找到<WebProjectProperties>xx</WebProjectProperties> 删掉 让后 重新 ...

  4. [android] soundpool简介

    主要的应用场景是游戏开发的时候,声音都比较短,比较密集,使用这个api来实现 池:实现了一个链表,旧的资源不会被释放掉,而是存起来,等用的时候,重新使用 不会创建过多的对象 在res资源目录里面创建一 ...

  5. ubuntu16.04LTS更换阿里源

    ubuntu16.04LTS更换阿里源 sudo gedit /etc/apt/sources.list 替换:    # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xe ...

  6. Web前端基础——jQuery(三)

    本文主要从以下几方面介绍jQuery应用中的内容: 1 jQuery 节点遍历2 jQuery 中的过滤器3 jQuery 属性操作4 jQuery Dom节点操作5 几个jQuery例子6 jQue ...

  7. 【github&&git】1、github中的watch、star、fork的作用

    [转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...

  8. [转] Mac下 快速写博客的软件 MarsEdit

    正文 marsedit最好. 这东西还是收费的,这里, 我给个注册码: Name: The Blade SN: RSME3-DA4KUN-3EL6Y-MXD2X-LYMT9-6KGX8-4 ~~~~~ ...

  9. The Maze Makers(csu1566)

    1566: The Maze Makers Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 90  Solved: 33[Submit][Status][ ...

  10. MathJax: 让前端支持数学公式

    文章图片存储在GitHub,网速不佳的朋友,请看<MathJax:让前端支持数学公式> 或者 来我的技术小站 godbmw.com 1. 必须要说 1.1 开发背景 博主使用Vue开发的个 ...