java 开发中常用方法
来源:互联网 发布:淘宝客博客网站源码 编辑:程序博客网 时间:2024/06/06 09:33
从List中拿出top指的条数数据:
我有几张阿里云幸运券分享给你,用券购买或者升级阿里云相应产品会有特惠惊喜哦!把想要买的产品的幸运券都领走吧!快下手,马上就要抢光了。
/** * 取top x条产品类数据 * * @param sourList 产品类集合 * @param rowsCount 条数 * @return List<ProductInfo> */ public static List<ProductInfo> limitProductInfoList(List<ProductInfo> sourList, int rowsCount) { List<ProductInfo> tempList = new ArrayList<>(); if (sourList != null) { int sourListSize = sourList.size(); if (rowsCount < sourListSize) { int subCount = sourListSize % rowsCount == 0 ? sourListSize / rowsCount : sourListSize / rowsCount + 1; int startIndext = 0; int stopIndext = 0; for (int i = 0; i < subCount; i++) { stopIndext = (i == subCount - 1) ? stopIndext + sourListSize % rowsCount : stopIndext + rowsCount; tempList = new ArrayList<ProductInfo>(sourList.subList(startIndext, stopIndext)); startIndext = stopIndext; if (tempList.size() > 0) { break; } } } else { tempList = sourList; } } return tempList; }
比较字符串是否在数组中:
private static String[] StarArray = new String[]{"DHTL", "IHTL", "GPKG", "GDIY", "GCRU"};ArrayUtils.contains(StarArray, "DHTL")
//验证对象为null
if (ObjectUtils.equals(sysRole, null)) { sysRole = this.getRole(systemCode, loginName);}
//验证List
if (CollectionUtils.isNotEmpty(sysRoleList)) { sysRole = sysRoleList.get(0);}
//验证字符串-验证时候忽略空白
if (StringUtils.isBlank(formData.getPost())){}
//验证字符串非空
if (StringUtils.isNotEmpty(userCard.getUID()))
/** * 清除空白字符 * * @param str * @return */ public static String trimAllWhitespace(String str) { if (str != null) { int len = str.length(); if (len > 0) { char[] dest = new char[len]; int destPos = 0; for (int i = 0; i < len; ++i) { char c = str.charAt(i); if (!Character.isWhitespace(c)) { dest[destPos++] = c; } } return new String(dest, 0, destPos); } } return str; } /** *list转换string * @param list List<String> * @param separator 分隔符 逗号等 * @return */ public static String listToString(List<String> list, char separator) { return org.apache.commons.lang.StringUtils.join(list.toArray(), separator); } /** *string转换list * @param str 分隔符字符串 * @param separator 逗号等 * @return List<String> */ public static List<String> stringToList(String str, String separator) { return java.util.Arrays.asList(str.split(separator)); }
阅读原文
http://click.aliyun.com/m/34920/
阅读全文
0 0
- java 开发中常用方法
- java开发中linux常用方法
- java 中常用方法
- java中常用方法
- IOS 开发中常用方法
- Java开发常用的方法
- Java开发常用方法汇总
- java中常用的方法
- Java中常用的方法
- java中常用字符串方法
- Java中常用的方法
- java 中String常用方法
- java中object常用方法
- java中split常用方法
- java中String 常用方法
- java API中常用方法
- java 中Throwable常用方法
- Java String中常用方法
- 【观察】让CFO新生!数字经济时代,如何迎接财务管理新浪潮?
- $routeProvider 路由
- deep learning 专项课程一 1.deep learning的介绍
- Google 推出 TensorFlow Lite 开发者预览版,在 iOS 和 Android 端部署人工智能
- 在eclipse中使用evosuite遇到了一些问题,提示windows找不到文件
- java 开发中常用方法
- sublime Text3
- Cron表达式:“/”与步增
- Hibernate二级缓存的配置及
- CheckBox位置错位的解决
- jQuery常用方法
- 常用默认端口号
- 关于CefSharp的坎坷之路
- 2017-11-10