package com.proxy.util;
import java.util.HashMap;
import java.util.Map;
/**
* @author: (le.qiao)
* @e-mail: qiaolevip@gmail.com
* @myblog: <a href="http://qiaolevip.iteye.com">http://qiaolevip.iteye.com</a>
* @date: 2012-8-17
*
*/
public class XmlWriter {
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put("thirduserid", "24396353");
map.put("thirdorderid", "2012050893537966006");
Map<String, String> map2 = new HashMap<String, String>();
map2.put("singleprice", "0.1");
map2.put("quantity", "2");
Map<String, Map<String, String>> map3 = new HashMap<String, Map<String, String>>();
map3.put("orderinfo", map);
map3.put("orderdeatil", map2);
XmlWriter.write(map3);
}
public static String write(Map<String, Map<String, String>> map) {
String reuslt = "";
StringBuffer sb = new StringBuffer();
sb.append("<api_respones xmlns:damaiapi=\"http://appapi.damai.cn/1.0\">\n");
if (map != null && map.size() > 0) {
for (Map<String, String> map2 : map.values()) {
for (String str : map2.values()) {
System.out.println(str);
}
}
}
return reuslt;
}
}
分享到:
相关推荐
代码里是相对有一丢丢复杂的,两层嵌套循环; 总(dataMap) deptName 部门名 list(Table)表的集合 <#list table as map> table1(map) table-名字 ${map.table} tableName-中文名 ${map.tableName} column...
Java比较for循环的处理时间,双重for循环优化,第一层循环转为Map, 通过空间换时间的方式来达到快速遍历的效果
JavaScript诞生已经有20多年了,我们一直使用的用来循环一个数组的方法是这样的: for (var index = 0; index < myArray.length; index++) { console.log(myArray[index]); } 自从JavaScript5起,我们开始可以...
010303_【第3章:Java基础程序设计】_判断与循环语句笔记.pdf 010401_【第4章:数组与方法】_数组的定义及使用笔记.pdf 010402_【第4章:数组与方法】_方法的声明及使用笔记.pdf 010403_【第4章:数组与方法】_数组...
7.2.2 使用foreach循环遍历集合元素 246 7.3 Set接口 247 7.3.1 HashSet类 247 学生提问:hashCode方法对于HashSet的作用是什么? 249 7.3.2 TreeSet类 252 7.3.3 EnumSet类 259 7.4 List接口 261 7.4.1 List...
forEach循环遍历 List<String> names = new ArrayList(); names.forEach(String x -> { System.out.println(x); System.out.println(x); }); Map,String> map = new HashMap(); map.forEach((x,y)...
掌握List集合、Set集合、Map集合的使用以及Iterator迭代器和foreach循环的使用 了解常用的集合类 熟悉泛型的使用
实例038 foreach循环优于for循环 47 实例039 终止循环体 48 实例040 循环体的过滤器 49 实例041 循环的极限 50 第3章 数组与集合的应用 51 3.1 数组演练 52 实例042 获取一维数组最小值 52 实例043 将二维数组中的...
使用map或filter等其他函数以小步骤从循环体中删除代码块。 最后使用一个Collector来收集流的结果。 有关这些重构步骤的几个详细示例,请参阅 Martin Fowler。 要涵盖的内容 转换mutation-and-for-loops 表现 并行化...
java版斗地主源码 斗地主游戏 version 2.0 说明文档 升级说明: 采用面向对象编程,理解子类与父类的关系,成员变量及类内方法的继承,父类方法的重写。 控制台流程控制。 重难点归纳: Map以及HashMap的定义方法、...
下面我们来根据value获取key,根据key获取value(1.foreach循环遍历 2.迭代器遍历) 举一个例子会更生动! 题目 创建一个Map集合,在集合中放入年份、世界杯冠军获得的国家。存储的键值对例如:“1994”,“巴西”;...
stream().foreach循环一些输出,仅限 Java8。 在stream上使用一种映射来处理数据并通过foreach输出。 使用sum获取数字的摘要。 使用parallel ,将无法确保顺序。 使用多个流来完成任务,即: map和flatMapToInt并 ...
foreach循环原理() volatile底层实现() equals和hashcode(, ) string,stringbuffer和stringbuilder(,,,, ) 伪泛型(, , ) 自动装箱(,) Try-with-resources() 序列化 反序列化(, , , ) interface 和 abstract class ...
6.6 foreach循环的循环计数器 6.7 小结 第7课 面向对象的陷阱 7.1 instanceof运算符的陷阱 7.2 构造器的陷阱 7.2.1 构造器之前的void 7.2.2 构造器创建对象吗 7.2.3 无限递归的构造器 7.3 持有当前类的实例...
一、什么是迭代器? 生成器概念在Java,Python等语言中都是具备的,ES6也添加到了JavaScript中。...ES5中遍历集合通常都是 for循环,数组还有 forEach 方法,对象就是 for-in,ES6 中又添加了 Map 和 Set,而迭代器
网上电商源码 java 燕窝2 Yanwte [ˈyænti] 代表另一种扩展方式。...循环的特征。 顾名思义,map reduce 节点接受提供者列表和reduce 函数以产生结果。 它基本上说提供者可以共存,但你需要协调他们的结果。 基于这个