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. rtf格式 C#设置字间距 CharacterSpacing

    richtextbox空间中操作行间距段间距都可以用发送消息解决,但是字间距却鲜有人关注,无法通过PARAFORMAT2消息解决,只能直接操作rtf格式 字间距主要就是要控制 expand expan ...

  2. [CF438E] 小朋友和二叉树

    Description 给定一个整数集合 \(c\),对于每个 \(i\in[1,m]\),求有多少种不同的带点权的二叉树使得这棵树点权和为 \(i\) 并且顶点的点权全部在集合 \(c\) 中.\( ...

  3. override与new的区别

    using System; namespace ConsoleAppDemo { class BaseClass { public void Fun() { Console.WriteLine(&qu ...

  4. hadoop fs,hadoop dfs,hdfs dfs

    hadoop fs: FS relates to a generic file system which can point to any file systems like local, HDFS ...

  5. Java容器类源码分析前言之集合框架结构(基于JDK8)

    一.基本概念 Java容器类库的用途是"保存对象",容器库类分为两个不同的分支. 1.Collection.可以保存一个或多个对象,将其保存为一个序列.Collection又可以细 ...

  6. idea 中使用 jetty 插件

    参考博客:http://blog.csdn.net/xiejx618/article/details/49936541

  7. Harbor 搜索镜像及查看 tag

    在我们搭建完 Harbor 后: https://www.cnblogs.com/klvchen/p/9482153.html 如果想要通过 API 获取 Harbor 上面的镜像及 tag 可以使用 ...

  8. App里面如何正确显示用户头像

    1.说明,一般用户头像在上传的时候都会处理为正方形,如果没有处理该怎么正确显示用户头像呢?解决方案:用css强制 在线地址移动端:戳这里 <div class="main-meimg& ...

  9. 二层协议--STP协议总结

    生成树协议的技术实现与配置注意点 一.stp协议的用途 二.stp协议的运行机制 三.stp协议规范

  10. 【转】巧用DOS tree命令+批处理 实现 指定文件 批量复制!

    转自:http://www.cnblogs.com/looky/archive/2010/01/24/1655292.html 今天一朋友叫我帮忙解决指定文件批量复制的问题,于是找了一大堆批处理命令, ...