Properties 转换成Map
转自:http://feitianbenyue.iteye.com/blog/1759259
对于Properties 转换成Map 的问题:
package com.feilong.example.util; import java.util.Properties;
import java.util.Map;
import java.util.HashMap;
import java.util.Set; public class PropertiesToMap {
public static void main(String[] args) { Properties properties = new Properties(); properties.setProperty("StrictHostKeyChecking", "no");
properties.setProperty("app.version", "1.0"); // Create a new HashMap and pass an instance of Properties. Properties
// is an implementation of a Map which keys and values stored as in a string.
Map<String, String> map = new HashMap<String, String>((Map) properties); // Get the entry set of the Map and print it out. Set propertySet = map.entrySet();
for (Object o : propertySet) {
Map.Entry entry = (Map.Entry) o;
System.out.printf("%s = %s%n", entry.getKey(), entry.getValue());
}
}
}
对于**.properties文件中数据的读取感觉很好用。
Properties 转换成Map的更多相关文章
- Dom4j把xml转换成Map(固定格式)
/** * 可解析list * * @param fileName * @return * @throws Exception */ @SuppressWarnings("unchecked ...
- Dom4j把xml转换成Map(非固定格式)
将xml转换成Map,能够应对不用结构的xml,而不是只针对固定格式的xml.转换规则:1.主要是Map与List的互相嵌套2.同名称的节点会被装进List 示例: import java.util. ...
- 分享非常有用的Java程序 (关键代码)(五)---把 Array 转换成 Map
原文:分享非常有用的Java程序 (关键代码)(五)---把 Array 转换成 Map import java.util.Map; import org.apache.commons.lang.Ar ...
- 将Object对象转换成Map 属性名和值的形式
将Java对象转换成Map的键值对形式 代码: package cn.lonelcoud.util; import com.sun.deploy.util.StringUtils; import ja ...
- 利用阿里巴巴封装的FastJSON来解析json并转换成map
利用阿里巴巴封装的FastJSON来解析json并转换成map package com.zkn.newlearn.json; import com.alibaba.fastjson.JSON; i ...
- 用于把List<Object>转换成Map<String,Object>形式
/** * 用于把List<Object>转换成Map<String,Object>形式,便于存入缓存 * @author zhang_bo * @param keyName ...
- Go开发Struct转换成map两种方式比较
最近做Go开发的时候接触到了一个新的orm第三方框架gorose,在使用的过程中,发现没有类似beego进行直接对struct结构进行操作的方法,有部分API是通过map进行数据库相关操作,那么就需要 ...
- c++ json字符串转换成map管理
在cocos2dx for lua中,我们经常通过lua的table传入c++使用,然后早c++层操作数据. 实现步骤大致如下: table->string->c++层->通过rap ...
- JDK8 Lamdba表达式转换成Map,value为null问题
// 将list转换成Map类型 Map<String, String> map = list.stream().collect(Collectors.toMap(Person::getI ...
随机推荐
- pthread_cond_timedwait时间设置
最近工作中需要在ACodec中起一个pthread,并每间隔100ms统计一次buffer的状态,在程序中使用pthread_cond_timedwait来设置时间间隔,但在使用中发现当超时时间设置成 ...
- 为网页设计师准备的30个使用的HTML5框架
原文地址:http://www.goodfav.com/zh/html5-framework-8189.html 网页设计师在开始使用一些应用程序之前需要考虑几个事实,以确保在应用Web程序框架时,这 ...
- CreateProcess error=206, The filename or extension is too long"的一个解决方案
在实际项目中我使用antrun 和 closure-compiler压缩JS项目.然后我就使用如下代码: 首先加入依赖. <dependency> <groupId>com.g ...
- Windows Azure Platform 系列文章目录
Windows Azure Platform (一) 云计算的出现 Windows Azure Platform (二) 云计算的分类和服务层次 Windows Azure Platform (三) ...
- JS认证Exchange
function ExchangeLogin() { vstrServer='<%=LocationUrl %>' vstrDomain = '<%=userLogin.AD %&g ...
- eCryptfs文件系统测试
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...
- 错误提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内 .
错误提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内 在做导出数据到EXCEL程序中,出现了错误提示:类型“GridView”的控件“Gr ...
- iconv 的参数问题
工作中遇到一个转码的问题,如下代码说话 void encode_convert(iconv_t& cd, const char* str, size_t str_len, std::strin ...
- Castle IOC容器内幕故事(下)
主要内容 1.ComponentModelBuilder 和 Contributors 2.Contributors分析 3.Handles分析 4.ComponentActivator分析 一.Co ...
- 【AS3 Coder】任务七:初涉PureMVC——天气预报功能实现
转自:http://www.iamsevent.com/post/36.html AS3 Coder]任务七:初涉PureMVC——天气预报功能实现 使用框架:AS3任务描述:了解PureMVC框架使 ...