方法 作用
isBlank 判断某字符串是否为空、长度为0、由空白符(whitespace) 构成。isBlank(" ")为true。多数情况用 isBlank
isEmpty 判断某字符串是否为空,为空的标准是 strnull 或 str.length()0。isEmpty(" ")为false
trim 去掉字符串两端的控制符(control characters, char <= 32)。如果为null或"",则返回null
strip 去掉字符串两端的空白符(whitespace)。如果输入为null则返回null
  • StringUtils 说明:
Operations on String that are null safe.

IsEmpty/IsBlank - checks if a String contains text
Trim/Strip - removes leading and trailing whitespace
Equals/Compare - compares two strings null-safe
startsWith - check if a String starts with a prefix null-safe
endsWith - check if a String ends with a suffix null-safe
IndexOf/LastIndexOf/Contains - null-safe index-of checks
IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut - index-of any of a set of Strings
ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters
Substring/Left/Right/Mid - null-safe substring extractions
SubstringBefore/SubstringAfter/SubstringBetween - substring extraction relative to other strings
Split/Join - splits a String into an array of substrings and vice versa
Remove/Delete - removes part of a String
Replace/Overlay - Searches a String and replaces one String with another
Chomp/Chop - removes the last part of a String
AppendIfMissing - appends a suffix to the end of the String if not present
PrependIfMissing - prepends a prefix to the start of the String if not present
LeftPad/RightPad/Center/Repeat - pads a String
UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize - changes the case of a String
CountMatches - counts the number of occurrences of one String in another
IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String
DefaultString - protects against a null input String
Rotate - rotate (circular shift) a String
Reverse/ReverseDelimited - reverses a String
Abbreviate - abbreviates a string using ellipsis or another given String
Difference - compares Strings and reports on their differences
LevenshteinDistance - the number of changes needed to change one String into another The StringUtils class defines certain words related to String handling. null - null
empty - a zero-length string ("")
space - the space character (' ', char 32)
whitespace - the characters defined by Character.isWhitespace(char)
trim - the characters <= 32 as in String.trim()

辅助字符串处理类:org.apache.commons.lang3.StringUtils的更多相关文章

  1. spring异常记录-----java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

    今天在练习怎样SSH中进行单元測试的时候出现下列异常: SEVERE: Exception starting filter Struts2 java.lang.NoClassDefFoundError ...

  2. Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

    1.错误叙述性说明 2014-7-10 23:12:23 org.apache.catalina.core.StandardContext filterStart 严重: Exception star ...

  3. NoClassDefFoundError: org/apache/commons/lang3/StringUtils

    出错信息: 2014-2-5 21:38:05 org.apache.catalina.core.StandardContext filterStart严重: Exception starting f ...

  4. Hadoop java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

    .jar 学习好友推荐案例的时候,提交运行时报错找不到StringUtils java.lang.ClassNotFoundException: org.apache.commons.lang3.St ...

  5. struts2中的错误--java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

    2013-4-7 10:13:56 org.apache.catalina.startup.HostConfig checkResources 信息: Reloading context [/chap ...

  6. ERROR----java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

    2013-4-28 13:17:57 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filte ...

  7. org.apache.commons.lang3.StringUtils中的StringUtils常用方法

    https://my.oschina.net/funmo/blog/615202?p=1 public static void TestStr(){ //null 和 ""操作~~ ...

  8. org.apache.commons.lang3.StringUtils类中isBlank和isEmpty方法的区别

    相信很多java程序员在写代码的时候遇到判断某字符串是否为空的时候会用到StringUtils类中isBlank和isEmpty方法,这两个方法到底有什么区别呢?我们用一段代码来阐述这个区别吧: @T ...

  9. 【java】java工具类StringUtils,org.apache.commons.lang3.StringUtils

    使用过程中,发现StringUtils工具类功能非常的多. 例如,判断元素是否为数字: StringUtils.isNumeric(string)

随机推荐

  1. Eclipse重命名项目名后如何彻底修改工程名

    背景:在Eclipse中当我们修改了一个Web项目名称后,在再次运行该项目,发现使用新的名称无法正常的浏览,而用旧的名称去可以 解决方案: 1:修改该项目目录下:.project文件 <?xml ...

  2. java中4种修饰符访问权限的区别

    访问权限 类 本包 子类 其他包 public √ √ √ √ protected √ √ √ x default(缺省) √ √ x x private √ x x x

  3. Adaboost入门教程——最通俗易懂的原理介绍(图文实例)

    https://blog.csdn.net/px_528/article/details/72963977 写在前面 说到Adaboost,公式与代码网上到处都有,<统计学习方法>里面有详 ...

  4. HMM模型和Viterbi算法

    https://www.cnblogs.com/Denise-hzf/p/6612212.html 一.隐含马尔可夫模型(Hidden Markov Model) 1.简介 隐含马尔可夫模型并不是俄罗 ...

  5. jw

    1.  ISO/OSI参考模型(七层)  应表会传 传输介质(双绞线,同轴电缆等)不在OSI7个层次之内 电气特性:电压表示0,1: 机械特性:接口形状,尺寸等 过程特性:出现顺序及信号线的工作原理 ...

  6. 玩转控件:重绘DEVEXPRESS中DateEdit控件 —— 让DateEdit支持只选择年月 (提供源码下载)

      前言 上一篇博文<玩转控件:重绘ComboBox —— 让ComboBox多列显示>中,根据大家的回馈,ComboBox已经支持筛选了,更新见博文最后最后最后面.   奇葩 这两天遇到 ...

  7. C#阿里云移动推送列表

    C#阿里云移动推送列表 这个就在上期随笔的基础之上,加一个 函数就行了.   简单的. 附上源码:一下代码只要把参数改一下就可以了,中间几个参数 可以灵活修改 /// <summary> ...

  8. Django(三)url和返回

    location 最后一个文件夹名就是project名,我用了Django_Plan. Application 是自动加入的APP名字,我用了Plan 编辑Django_Plan\Django_Pla ...

  9. Java通过class文件得到所在jar包

    今天遇到一个问题,需要通过知道的class文件得到该文件所在的jar包,试过很多办法都不行,最后在网上找到了一个解决办法,如下: demo.java 1 2 String path = XXX.cla ...

  10. 老毛桃PE修改方法(屏蔽更改主页,屏蔽加装的绿色浏览器)

    虽然老毛桃早就退隐了,虽然这个老毛桃不是曾经那个老毛桃~但是不得不说这个老毛桃PE还是有很多人在用~而且这个老毛桃的PE兼容性,个人认为还是很不错的.就是有暗扣,每次加装一个“绿色浏览器”和锁定主页, ...