空指针异常让人厌恶,恐怕是实际应用中出现次数最多的异常了,下面是如何避免NullPointerException出现的技巧 使用Apache的lang包的工具类来判空和非空:StringUtils和CollectionUtils ...
分类:
编程语言 时间:
2018-07-26 23:45:54
阅读次数:
256
1、Mapper类package cn.sjq.bigdata.mr.salary;import java.io.IOException;import org.apache.commons.lang.StringUtils;import org.apache.hadoop.io.LongWritable;import org.apache.hadoop.io.Text;import org.apa
分类:
其他好文 时间:
2018-07-26 10:50:51
阅读次数:
254
1 import com.alibaba.fastjson.JSON; 2 import com.alibaba.fastjson.serializer.SerializerFeature; 3 import org.springframework.util.StringUtils; 4 5 imp... ...
分类:
其他好文 时间:
2018-07-21 14:41:38
阅读次数:
171
1 isNotEmpty(str)等价于 str != null && str.length > 0 2 isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length > 0 3 同理 4 isEmpty 等价于 str... ...
分类:
编程语言 时间:
2018-07-19 16:09:14
阅读次数:
207
原文地址:https://www.cnblogs.com/dennisit/p/3705374.html org.apache.commons.lang.StringUtils类提供了String的常用操作,最为常用的判空有如下两种isEmpty(String str)和isBlank(String ...
分类:
其他好文 时间:
2018-07-07 17:42:21
阅读次数:
177
/** * 去掉文本中的html标签 * * @param inputString * @return */ public static String html2Text(String inputString) { if (StringUtils.isEmpty(inputString)) { re ...
分类:
编程语言 时间:
2018-07-05 23:13:57
阅读次数:
163
最近遇到了很多的问题,所以我要记录下来,记录自己的成长过程。 要在工程的lib文件夹中导入commons.lang.2.6的jar包。 下载地址:http://commons.apache.org/proper/commons-lang/download_lang.cgi ...
分类:
Web程序 时间:
2018-06-30 14:36:48
阅读次数:
941
# 建议直接使用的第三方类 Common Lang =》StringUtils =》Validate Guava =》Cache =》Ordering JDK7(LTS JDK8 JDK11...) =》Arrays =》Collections ……………………………………………………………………… ...
isNotEmpty将空格也作为参数,isNotBlank则排除空格参数 参考 StringUtils方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出NullPointerE ...
分类:
其他好文 时间:
2018-06-08 15:44:26
阅读次数:
156
StringUtils常用方法+StringUtils详细介绍 StringUtils用法+StringUtils详细介绍博文来源:http://yijianfengvip.blog.163.com/blog/static/175273432201212221935832/public static ...
分类:
其他好文 时间:
2018-06-08 11:55:24
阅读次数:
186