- 浏览: 122360 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (165)
- 数据库 (45)
- 架构 (0)
- java web前端+框架 (9)
- java web后端+框架 (56)
- Eclipse插件 (1)
- 解题思路 (2)
- Eclipse (2)
- linux (6)
- jquery (4)
- 正则 (3)
- jsp (1)
- javascript (8)
- oracle (39)
- 生活 (1)
- weblogic (5)
- tomcat (3)
- Jrebel (1)
- powerdesigner (1)
- svn (1)
- log4j (1)
- IDE (1)
- POI (2)
- jvm (2)
- ssh (1)
- http (1)
- notepad++ (2)
- 润乾 (1)
- 设计模式 (0)
- 实用类Utils (2)
- 算法 (1)
- xml (1)
- 实用类 (2)
最新评论
/**
* List实用类
*
* @author vernon.chen
*
*/
public class BeanUtils extends org.apache.commons.collections.ListUtils {
/**
* <p>
* 将List变为Map
* </p>
*
* @param list
* @param <V>
* list的项目
* @param keyField
* 作为Map的项目
* @return 变换成的Map
* @throws Exception
* keyField项目没有找到的话,抛出异常
*/
public static <V> Map<String, V> listToMap(
List<V> list,
String keyField)
{
Map<String, V> map = new HashMap<String, V>();
for (V obj : list) {
String key = null;
try {
key = BeanUtils.getProperty(obj, keyField);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
map.put(key, obj);
}
return map;
}
}
* List实用类
*
* @author vernon.chen
*
*/
public class BeanUtils extends org.apache.commons.collections.ListUtils {
/**
* <p>
* 将List变为Map
* </p>
*
* @param list
* @param <V>
* list的项目
* @param keyField
* 作为Map的项目
* @return 变换成的Map
* @throws Exception
* keyField项目没有找到的话,抛出异常
*/
public static <V> Map<String, V> listToMap(
List<V> list,
String keyField)
{
Map<String, V> map = new HashMap<String, V>();
for (V obj : list) {
String key = null;
try {
key = BeanUtils.getProperty(obj, keyField);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
map.put(key, obj);
}
return map;
}
}
发表评论
-
eclipse java代码格式化 javaformatter20150123.zip
2015-01-23 11:30 666eclipse java代码格式化 javaformatter ... -
List to Map
2015-01-21 17:22 437/** * <p>将List变为Map</p ... -
读取access工具类-ReadAccessUtil2
2015-01-06 13:52 506import com.healthmarketscience. ... -
ParameterizedType获取java泛型参数类型
2014-11-14 15:15 663ParameterizedType获取java泛型参数类型 ... -
分页帮助类-oracle-java
2014-10-09 17:46 420/** * 分页帮助类 * * @author ver ... -
java自动实例化List AutoArrayList
2014-07-21 15:51 704import java.util.ArrayList; p ... -
单一登录过滤器
2014-06-20 17:13 363/** * 单一登录过滤器 * * @author v ... -
正则 java 查找 打印 所有匹配项
2014-06-18 11:26 598package com.test.regex; import ... -
第3方包读取Access
2014-05-26 16:07 625package com.test; import java. ... -
多线程加签验签例子.zip
2014-05-26 16:08 479多线程加签验签例子.zip -
DateTimeUtils
2014-05-26 16:08 616import java.text.DateFormat; im ... -
JdbcTemplateRowMapper
2015-05-19 15:44 536import java.lang.reflect.Constr ... -
KeyValuePair2
2015-05-19 15:44 468/** * 键值对 * * @author verno ... -
OrderUtil -排序工具
2014-05-22 09:35 613/** * 排序工具 * * @author vern ... -
ZipUtils
2014-05-22 09:35 421import java.io.BufferedOutputSt ... -
TimerUtils
2014-05-22 09:34 434import org.slf4j.Logger; import ... -
Excel View 4 Spring
2014-05-22 09:29 302Excel View 4 Spring @RequestMa ... -
DOMUtils xml操作实用类
2014-04-07 21:41 776/* * Copyright 2001-2004 The A ... -
生成验证码 数学+字母
2014-04-01 10:08 399public static String getCharAnd ... -
ConnUtils2程序耗时输出 oracle.sql.Clob类型转换成String类型
2014-03-29 10:00 651package com.achievo.ems.web.ser ...
相关推荐
javascript 模拟 java中的 List,Map js文件为 js/utils.js IE6.0 测试通过 <br>List: add(var obj) //添加一个元素 remove(var index) //删除一个元素 get(var index) //获取一个元素 remove...
Java中 List《map》把里面map中某个key相同记录的其他key 的 value 合并 Java中 List《map》把里面map中某个key相同记录的其他key 的 value 合并
Google转Map图层
主要介绍了在Java 8中将List转换为Map对象方法,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下
Json格式的字符串转成List、Array、Map、Object、List等,就是各种字符串转其他格式的方法.有个封装好的转换方法和一个我自己做的示例
NULL 博文链接:https://wuniu2010.iteye.com/blog/1771934
查询返回map或list<Map>时,针对大小写以及下划线,横杠(USER_NAME,USER-NAME),转化为标准的java变量类型userName,支持互相转化。
map 和 bean 之间的转换,可以利用反射的原理实现
String list 转化为 String, 使用Stringbuffer 。。。。。。。。。。。。。。。
NULL 博文链接:https://cxwitjy.iteye.com/blog/1456617
将json转换为map之后,如果数值类型太多会在转换之后出现科学计数法的问题,经研究jackson源码、网上百度资料得知可以通过设置一些参数解决该问题
192、Can I use Hidden form field to track session? 45 194、In a architecture pattern like MVC, it is mandatory that Servlet should be the controller, why not JSP? 46 195、Why JSP is used as View part ...
unordered-list-to-mind-mapAn example that converts html unordered list to mind map using kityminder-core使用百度脑图的 kityminder-core,将 HTML 无序列表转换为思维导图的示例How to UseYou will find the ...
接口调用时,数据的交互传输,有toObject,toJson,toList,toMap
Map的规范为:map(function_to_apply, list_of_inputs) 大多数时候,我们需要将列表中的所有元素一个个传递给一个函数,并收集输出。例如: items = [1, 2, 3, 4, 5] squared = [] for i in items: squared....
主要介绍了Java中快速把map转成json格式的方法,本文使用json-lib.jar中的JSONSerializer.toJSON方法实现快速把map转换成json,需要的朋友可以参考下
the last tutorial, you’ll have created a simple to-do list app. After you’ve built your first app in this guide and are considering your next endeavor, read the fourth module. It explores the ...
• List of LUNs exposed to hosts • Information about a specific LUN that is exposed to the host.
excel数据替代接口数据转json,目前还在完善,list集合下只能放一个map
java 开发者 配置jdk1.8 一下是jdk1.8的... List<Integer> c = names.stream.map(x->x.length()).collect(Collectors.toList()); List<Integer> c = names.stream.map(String::length).collect(Collectors.toList());