javaIO之Properties:读取*.properties配置文件
来源:互联网 发布:淘宝差评怎么删除不了 编辑:程序博客网 时间:2024/05/22 16:52
1、需求:用java读取e:\demo.properties配置文件
username=rootpassword=12345address=beijing
2、涉及到Properties这个类:
package com.insigma.zd.group4.liuchao.languagebase;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import java.io.UnsupportedEncodingException;import java.util.Iterator;import java.util.Properties;public class PropertiesDemo {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubProperties pro = new Properties();try {FileInputStream fis = new FileInputStream("e:/demo.properties");try {pro.load(new InputStreamReader(fis,"gbk"));Iterator<Object> it = pro.keySet().iterator();while(it.hasNext()){Object key = it.next();System.out.println(key+"="+pro.get(key));}} catch (UnsupportedEncodingException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
3、Properties的load()方法读取InputStream,读取properties文件,然后用迭代器循环输出key和value。
4、国际化方面也会用到properties文件
- javaIO之Properties:读取*.properties配置文件
- JDBC链接之读取配置文件properties
- java 读取properties配置文件
- Java读取properties配置文件
- 读取properties配置文件
- java读取properties配置文件
- java 读取配置文件properties
- 读取.properties配置文件
- java 读取*.properties配置文件
- Java读取properties配置文件
- java 读取配置文件(properties)
- java读取 .properties配置文件
- Properties 读取配置文件
- java读取properties配置文件
- Properties配置文件读取
- spring 读取properties配置文件
- 读取Properties配置文件内容
- 读取.properties配置文件
- 常用集成电路引脚识别方法
- winlogon源码分析
- 三大框架建立Web项目,所需jar包和各个jar包
- 归档Redis在Windows,linux平台下的安装配置
- oracle 11g导出空表处理
- javaIO之Properties:读取*.properties配置文件
- 简单的Memory leak跟踪(一) DEBUG_NEW方案
- 转载并记录一遍关于骨骼动画的cocos2d论坛帖子。
- Struts2的属性驱动与模型驱动的区别
- ubuntu下移植ffmpeg到android
- 管理要像一部好电影
- WIZ610wi用户手册-版本 1.9.1(二)
- vc 创建桌面快捷方式
- 浅析C#中new、override、virtual关键字的区别