txt文件操作

// txt文件操作
Properties prop = new Properties();
String s = "Height=200";
String s2 = "Width=15";
FileOutputStream fos = new FileOutputStream("properties.txt");
fos.write(s.getBytes());
fos.write("\r\n".getBytes());
fos.write(s2.getBytes()); FileInputStream fis = new FileInputStream("properties.txt");
prop.load(fis); // txt:从输入字节流读取
prop.list(System.out);
System.out.println(prop.get("Height"));

xml文件操作

// xml文件操作
Properties prop = new Properties();
prop.put("Height", "200");
prop.put("Width", "15");
FileOutputStream fos = new FileOutputStream("properties.xml");
prop.storeToXML(fos, "Properties Example"); // xml:输出流写入 FileInputStream fis = new FileInputStream("properties.xml");
prop.loadFromXML(fis); // xml:从输入流读取properties
prop.list(System.out); Set<String> set = prop.stringPropertyNames();
System.out.println(set)

java Properties的更多相关文章

  1. Java Properties工具类详解

    1.Java Properties工具类位于java.util.Properties,该工具类的使用极其简单方便.首先该类是继承自 Hashtable<Object,Object> 这就奠 ...

  2. java:Properties属性文件概念

    java:Properties属性文件概念 在java之前的国际化程序中提出了一个属性文件的概念,属性文件的后缀是:*.properties,那么在java中提供了意个属性文件的专门操作类,Prope ...

  3. java properties类读取配置文件

    1.JAVA Properties类,在java.util包里,具体类是java.util.properties.Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值 ...

  4. 基于Java Properties类设置本地配置文件

    一.Java Properties类介绍 Java中有个比较重要的类Properties(Java.util.Properties),主要用于读取Java的配置文件,各种语言都有自己所支持的配置文件, ...

  5. Java Properties的使用

    转自:https://www.cnblogs.com/bakari/p/3562244.html 一.Java Properties类 Java中有个比较重要的类Properties(Java.uti ...

  6. Java Properties集合基础解析

    Java Properties集合基础解析 本期学习的properties集合是项目中经常用到的操作 什么是Properties集合? java.util.Properties集合继承于Hashtab ...

  7. java Properties异常:Malformed \uxxxx encoding.

    昨天项目中遇到一个 java.lang.IllegalArgumentException: Malformed \uxxxx encoding.这样的一个异常,debug了一下发现是读取propert ...

  8. java Properties 配置信息类

    Properties(配置信息类):主要用于生产配置文件和读取配置文件信息. ----> 是一个集合类 继承HashTable 存值是以键-值的方式. package com.beiwo.io; ...

  9. 【JAVA Properties类概述】

    一.概述. 之前说过,该对象是和IO流相结合的技术,所以和IO流结合在一起来讲比较合适. public class Propertiesextends Hashtable<Object,Obje ...

  10. java properties读取与设值

    import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream; ...

随机推荐

  1. 372.Definition of ListNode

    单项列表只能把后一个node中的所有数据copy到当前node再delete后一node. /** * Definition of ListNode * class ListNode { * publ ...

  2. JavaList addAll removeAll

    List<String>list1=new ArrayList<>(); list1.add("a"); list1.add("b"); ...

  3. 版本控制--git+idea

  4. python爬虫之短信报警

    1 import smtplib import email.mime.multipart import email.mime.text def send_email(content=''): &quo ...

  5. Ansible入门与实践

    一.ansible介绍 Ansible是一个简单的自动化运维管理工具,基于Python语言实现,由Paramiko和PyYAML两个关键模块构建,可用于自动化部署应用.配置.编排task(持续交付.无 ...

  6. shit vue & shit iview

    shit vue & shit iview <Switch> !== <i-switch> https://www.iviewui.com/components/swi ...

  7. Python学习之路—————day04

    今日内容: 1. 循环语句 1.1 if判断 1.2 while循环 1.3 for循环 一.if判断 语法一: if 条件 代码块1 代码块2 代码块3 # 例: sex='female' age= ...

  8. .net core compatibility windows & windows compatible Linux

    Who is this package for? This package is meant for developers that need to port existing .NET Framew ...

  9. 行为驱动开发(BDD) - 深入了解

    行为驱动开发(BDD) - 一个快速的描述和示例 BDD表示乙 ehavior ð里文ð才有发展.用于描述行为的语法是Gherkin. 这个想法是尽可能自然地描述一种语言应该发生什么. 如果你熟悉单元 ...

  10. vuex2.0 基本使用(2) --- mutation 和 action

    我们的项目非常简单,当点击+1按钮的时候,count 加1,点击-1按钮的时候,count 减1. 1, mutation The only way to actually change state ...