/*
为了更大的灵活性,当构造一个属性(Properties)对象时,指定一个默认的属性列表。如果在主列表中没有发现期望的关键字,将会搜索默认列表。
*/
//Use a default property list.
import java.util.*;
class PropDemoDef{
public static void main(String[] args)
{
Properties defList = new Properties();
defList.put("JiLin","ChangChun");
defList.put("ShanDong","JiNan");
Properties capitals = new Properties(defList);
Set provinces;
String str;
capitals.put("JiangSu","NanJing");
capitals.put("LiaoNing","ShenYang");
capitals.put("ShanXi","XiAn");
capitals.put("HeBei","ShiJiaZhuang");
//show all provinces and captials in hashtable
provinces = capitals.keySet(); //get set-view of keys
Iterator i = provinces.iterator();
while(i.hasNext()){
str = (String)i.next();
System.out.println("The captial of " + str + " is " + capitals.getProperty(str) + " .");
}
System.out.println();
//JiLin will now be found in the default list.
str = capitals.getProperty("JiLin");
System.out.println("The captial of JiLin is " + str + " .");
}
}
分享到:
相关推荐
log4j-1.2.16.jar与slf4j-api-1.6.1.jar加个转换包和log4j.properties示例
多种方式读取Properties代码示例
Properties方法示例1
使用java.util.Properties类的load()方法 示例: InputStream in = lnew BufferedInputStream(new FileInputStream(name)); Properties p = new Properties(); p.load(in); 2。使用java.util....
Properties类表示了一个持久的属性集。Properties可保存在流中或从流中加载。属性列表中每个键及其对应值都是一个字符串。本文使用java读取这些属性,看下面详细介绍吧
log4j-1.2.16.jar与slf4j-api-1.6.1.jar加个转换包和log4j.properties示例。。下载即用
读取properties文件路径的两种方式.zip 文档说明+项目示例
Kotlin多平台项目示例该项目为Kotlin ... credentials.properties示例重命名为credentials.properties 每个变量的输入值。 例如: bintray.user=userIDbintray.apikey=APIKey如果您不需要发布到Bintray,只需确保文件存
火花流入水槽 火花指标下沉到InfluxDb 为什么这有用? 由于Spark具有分布式特性,因此很难... metrics.properties示例片段的示例: *.sink.influx.class=org.apache.spark.metrics.sink.InfluxDbSink *.sink.influx.
API读取Properties文件的六种方法2009-03-02 08:57使用J2SE API读取Properties文件的...示例: InputStream in = lnew BufferedInputStream(new FileInputStream(name)); Properties p = new Properties(); p.load(in);
HttpRestWebService ##指示: 在〜\ Cache \ src \ main \ resources \ cache.properties示例属性文件中设置缓存设置: cacheDuration=30000 cacheSizeBytes=150000 cacheSizeElements=10启动缓存服务器: 使用...
[toc] mybatis-generator-plus 特点: 1.生成代码入口:...1.配置 application.properties 示例 #数据库配置 spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEnc
myeclipse 6.0.1 properties文件文中乱码问题详细解决: 1。包括各个版本eclipse的插件;... native2ascii 手动转化的 最简单易用示例 3。 包括网上下载的其它properties解决方法和native2ascii操作的详细介绍。
提取-从primaryKey和secondaryKey检索项目删除-删除项目保存-更新或创建项目查询功能概念活动记录待定NoSQL 待定实时云存储待定注解待定如何使用玛文尚未创建构型storage.properties示例storage.application_...
本篇文章主要介绍了Java代码实现对properties文件有序的读写的示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
wechat4j####介绍:wechat4j是一个使用纯JAVA来封装的一个微信JAVA框架,此框架主要是为了方便处理与...在resources文件夹下面新建文件wechat4j.properties示例内容:appId=wxd30e31bfd8c207exappSecret=d0f9c44269c