方法 作用
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. Oracle性能诊断艺术-读书笔记

    create table test0605 as select * from dba_objects; select t1.owner,t1.object_name,t1.object_id from ...

  2. xhost + 的作用

    xhost 是用来控制X server访问权限的. 通常当你从hostA登陆到hostB上运行hostB上的应用程序时, 做为应用程序来说,hostA是client,但是作为图形来说, 是在hostA ...

  3. OC Copy自定义类

  4. c++ 发送消息,模拟拖拽文件

    #include <ShlObj.h> BOOL SimulateDropFile(CString strFilePath) { }; wcstombs(szFile, strFilePa ...

  5. Oracle11g 表空间使用监控

    SELECT * FROM (select * from (select a.TABLESPACE_NAME TABLESPACE_NAME,(a.total || 'M') AS "SUM ...

  6. linux上定时运行scrapy

    1 运行方式一 (proxy-ip) [root@192 ~]# cd /data/test-proxy-ip/ (proxy-ip) [root@192 test-proxy-ip]# scrapy ...

  7. hdu 1013 过山车 匈牙利算法(代码+详细注释)

    过山车 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  8. 基于资源名的MVC权限控制

    在程序复杂程度不断上升的过程中,无可避免需要触碰到权限控制,而权限控制又与业务逻辑紧紧相关,市场上出现了大量的权限控制产品,而程序的开发,讲究去繁化简的抽象,在我的开发过程中,逐渐发现程序的权限控制核 ...

  9. tomcat用户配置,内存配置,pid配置

    一:tomcat用户配置 1.打开 webapps\manager\WEB-INF\web.xml 可以看到tomcat所有的角色名,后面我们就是需要配置这些角色 2.给用户添加角色 打开 conf/ ...

  10. 关于rimworld(边缘之地)

    低缓的音乐   广阔的原野  丰富而不杂乱的地表  完美的殖民拓荒世界. 各种随机地形,丰富的资源.林木与矿产.随机生成的大世界给人真实世界的感觉. 动态而和谐的画面,随风摇摆的植被,跳跃的兔子,以及 ...